Hello Programmers/Coders, Today we are going to share solutions of Programming problems of HackerRank, Algorithm Solutions of Problem Solving Section in Java. At Each Problem with Successful submission with all Test Cases Passed, you will get an score or marks. And after solving maximum problems, you will be getting stars. This will highlight your profile to the recruiters.
In this post, you will find the solution for Game of Thrones – I in Java-HackerRank Problem. We are providing the correct and tested solutions of coding problems present on HackerRank. If you are not able to solve any problem, then you can take help from our Blog/website.
Use “Ctrl+F” To Find Any Questions Answer. & For Mobile User, You Just Need To Click On Three dots In Your Browser & You Will Get A “Find” Option There. Use These Option to Get Any Random Questions Answer.
Introduction To Algorithm
The word Algorithm means “a process or set of rules to be followed in calculations or other problem-solving operations”. Therefore Algorithm refers to a set of rules/instructions that step-by-step define how a work is to be executed upon in order to get the expected results.
Advantages of Algorithms:
- It is easy to understand.
- Algorithm is a step-wise representation of a solution to a given problem.
- In Algorithm the problem is broken down into smaller pieces or steps hence, it is easier for the programmer to convert it into an actual program.
Link for the Problem – Game of Thrones – I – Hacker Rank Solution
Game of Thrones - I – Hacker Rank Solution
Problem:
Dothraki are planning an attack to usurp King Robert’s throne. King Robert learns of this conspiracy from Raven and plans to lock the single door through which the enemy can enter his kingdom.

But, to lock the door he needs a key that is an anagram of a palindrome. He starts to go through his box of strings, checking to see if they can be rearranged into a palindrome. Given a string, determine if it can be rearranged into a palindrome. Return the string YES
or NO
.
Example
One way this can be arranged into a palindrome is . Return YES
.
Function Description
Complete the gameOfThrones function below.
gameOfThrones has the following parameter(s):
- string s: a string to analyze
Returns
- string: either
YES
orNO
Input Format
A single line which contains .
Constraints
- |s|
- contains only lowercase letters in the range
Sample Input 0
aaabbbb
Sample Output 0
YES
Explanation 0
A palindromic permutation of the given string is bbaaabb.
Sample Input 1
cdefghmnopqrstuvw
Sample Output 1
NO
Explanation 1
Palindromes longer than 1 character are made up of pairs of characters. There are none here.
Sample Input 2
cdcdcdcdeeeef
Sample Output 2
YES
Explanation 2
An example palindrome from the string: ddcceefeeccdd.
Game of Thrones - I – Hacker Rank Solution
import java.util.Scanner; /** * @author Techno-RJ * */ public class GameOfThronesI { static String gameOfThrones(String s) { int a[] = new int[26]; for (int i = 0; i < s.length(); i++) { int index = s.charAt(i) - 'a'; a[index]++; } int oddCount = 0; for (int i = 0; i < 26; i++) { if (a[i] != 0) { if ((a[i] & 1) == 1) { oddCount++; } } } return oddCount > 1 ? "NO" : "YES"; } public static void main(String[] args) { Scanner in = new Scanner(System.in); String s = in.next(); String result = gameOfThrones(s); System.out.println(result); in.close(); } }
order cialis online buy cialis generic low cost ed pills
order cefadroxil 500mg generic propecia without prescription buy propecia 5mg sale
buy generic estrace order prazosin 2mg generic order prazosin without prescription
mebendazole uk tretinoin gel us buy tadalafil 20mg online
buy metronidazole paypal cephalexin over the counter buy cephalexin 500mg
cleocin 150mg without prescription buy cleocin online buy ed pills generic
order bimatoprost buy generic trazodone for sale desyrel 100mg price
catapres 0.1mg oral order meclizine 25 mg pill tiotropium bromide 9mcg cheap
sildenafil 50mg us sildenafil 100mg uk sildenafil pills 100mg
minocin uk minocycline 50mg oral actos pill
cialis 20mg usa cost tadalafil 20mg cialis cheap
buy generic azithromycin order gabapentin 600mg sale neurontin 800mg brand
oral ivermectin cost purchase stromectol pills buy prednisone pills
lasix uk brand monodox order ventolin 2mg pills
buy vardenafil pills for sale generic hydroxychloroquine 400mg plaquenil canada
purchase altace ramipril us arcoxia 60mg price
buy vardenafil 20mg online buy plaquenil tablets cost hydroxychloroquine 200mg
asacol 800mg uk buy azelastine 10 ml sprayers irbesartan 150mg tablet
olmesartan price buy generic depakote 500mg order divalproex 250mg generic
buy generic clobetasol buspirone 10mg sale cordarone 200mg brand
buy clobetasol no prescription buspar generic buy amiodarone without a prescription
carvedilol 25mg over the counter purchase chloroquine generic buy chloroquine tablets
order acetazolamide 250 mg buy diamox pills order imuran 50mg
lanoxin medication buy generic micardis 80mg order molnupiravir generic
order naproxen omnicef over the counter order prevacid 30mg pills