# Game of Thrones - I

### Problem Statement :

```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

s = 'aabbccdd'

One way this can be arranged into a palindrome is aabbccdd. 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 or NO

Input Format

A single line which contains s.

Constraints

1  <=   |s|   <=  10^5
s contains only lowercase letters in the range ascii[a . . . z ]```

### Solution :

```                            ```Solution in C :

In  C++  :

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main() {
int a[26]={0};
string s;
cin>>s;
int l=s.length();
for(int i=0;i<l;i++)
{
(a[s[i]-'a'])++;
}
int c=0;
for(int i=0;i<26;i++)
{
if(a[i]%2)
c++;
}
if(c>1)
cout<<"NO";
else
cout<<"YES";
return 0;
}

In  Java  :

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Solution {
static String s;
static int hash[];
public static void main(String[] args) {
hash=new int[26];
Scanner sc = new Scanner(System.in);
s=sc.next();
s.toUpperCase();
int i;
for(i=0;i<s.length();i++)
{
int temp;
temp=s.charAt(i)-'a';

hash[temp]=hash[temp]+1;
}
int odd=0;
int set=0;
for(i=0;i<26;i++)
{
if(hash[i]%2!=0)
{
if(odd==1){set=1;break;}
else odd=1;
}
}
if(set==0)
System.out.println("YES");
else if(set==1)
System.out.println("NO");
}
}

In  C :

#include<stdio.h>

int main()
{
int a[26],i,tp;
char c;
for (i=0;i<26;i++)
a[i]=0;
while ((c=getchar())!=EOF&&c!='\n')
{
a[c-97]++;
}
tp=1;
for (i=0;i<26;i++)
{
if (a[i]%2!=0&&tp==1)
tp=0;
else if (a[i]%2!=0&&tp==0)
{
printf("NO");
break;
}
}
if (i==26)
printf("YES");
return 0;
}

In   Python3  :

string = input()
character_count = {}
for i in string:
if i not in character_count:
character_count[i] = string.count(i)
odd_counts = 0
for i in character_count:
if character_count[i] % 2 == 1:
odd_counts += 1
if odd_counts > 1:
print("NO")
else:
print("YES")```
```

## Get Node Value

This challenge is part of a tutorial track by MyCodeSchool Given a pointer to the head of a linked list and a specific position, determine the data value at that position. Count backwards from the tail node. The tail is at postion 0, its parent is at 1 and so on. Example head refers to 3 -> 2 -> 1 -> 0 -> NULL positionFromTail = 2 Each of the data values matches its distance from the t

## Delete duplicate-value nodes from a sorted linked list

This challenge is part of a tutorial track by MyCodeSchool You are given the pointer to the head node of a sorted linked list, where the data in the nodes is in ascending order. Delete nodes and return a sorted list with each distinct value in the original list. The given head pointer may be null indicating that the list is empty. Example head refers to the first node in the list 1 -> 2 -

## Cycle Detection

A linked list is said to contain a cycle if any node is visited more than once while traversing the list. Given a pointer to the head of a linked list, determine if it contains a cycle. If it does, return 1. Otherwise, return 0. Example head refers 1 -> 2 -> 3 -> NUL The numbers shown are the node numbers, not their data values. There is no cycle in this list so return 0. head refer

## Find Merge Point of Two Lists

This challenge is part of a tutorial track by MyCodeSchool Given pointers to the head nodes of 2 linked lists that merge together at some point, find the node where the two lists merge. The merge point is where both lists point to the same node, i.e. they reference the same memory location. It is guaranteed that the two head nodes will be different, and neither will be NULL. If the lists share

## Inserting a Node Into a Sorted Doubly Linked List

Given a reference to the head of a doubly-linked list and an integer ,data , create a new DoublyLinkedListNode object having data value data and insert it at the proper location to maintain the sort. Example head refers to the list 1 <-> 2 <-> 4 - > NULL. data = 3 Return a reference to the new list: 1 <-> 2 <-> 4 - > NULL , Function Description Complete the sortedInsert function

## Reverse a doubly linked list

This challenge is part of a tutorial track by MyCodeSchool Given the pointer to the head node of a doubly linked list, reverse the order of the nodes in place. That is, change the next and prev pointers of the nodes so that the direction of the list is reversed. Return a reference to the head node of the reversed list. Note: The head node might be NULL to indicate that the list is empty.