## Amazon Interview Question for Quality Assurance Engineers

Team: AmazonMusic
Country: United States
Interview Type: Phone Interview

Comment hidden because of low score. Click to expand.
0
of 0 vote

def toDict(strA):
setA = set(list(strA))
dict={}
for char in setA:
dict.update({char:strA.count(char)})
print(dict)

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````def toDict(strA):
setA = set(list(strA))
dict={}
for char in setA:
dict.update({char:strA.count(char)})
print( dict )``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````def toDict(strA):
setA = set(list(strA))
dict={}
for char in setA:
dict.update({char:strA.count(char)})
print(dict)``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````public static string Calculatefrequency(string chars) {
Dictionary<char, int> freq = new Dictionary<char, int>();
foreach(var c in chars) {
// update the char value(counter) if its in dictionary
if (freq.ContainsKey(c)) {
int counter;
freq.TryGetValue(c, out counter);
counter = counter + 1;
freq[c] = counter;
} else {
}
}
string result = "";
foreach(var f in freq) {
result += "(" + f.Key + "," + f.Value + ")";
}

return result;
}``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````#include <iostream>
#include <string.h>
using namespace std;

int main() {
char str[10000];
cin>>str;
int count[26]={0};
bool charvisit[26]={false};
int l=strlen(str);
for(int i=0;i<l;i++)
count[str[i]-97]++;
for(int i=0;i<l;i++)
{
if(charvisit[str[i]-97]==false)
{
cout<<char(str[i])<<" "<<count[str[i]-97]<<endl;
charvisit[str[i]-97]=true;
}
}
return 0;
}``````

Comment hidden because of low score. Click to expand.
0
of 2 vote

public void charCounter(String word) {
for (int i = 0; i < word.length(); i++) {
if (charcount.get(word.charAt(i)) == null) {
charcount.put(word.charAt(i), 1);
} else {
charcount.put(word.charAt(i), charcount.get(word.charAt(i)) + 1);
}}

for (Map.Entry<Character, Integer> count : charcount.entrySet()) {
System.out.print(count.getKey() + "(" + count.getValue() + ")");
}}

Comment hidden because of low score. Click to expand.
0

I dont think the code orders the elements as they appear in the original array.

a should come before b and b should appear before c.....

Comment hidden because of low score. Click to expand.
0
of 0 vote

using hashtable

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````string s;
cin>>s;
int n=s.size();
int freq[26];
for(int i=0;i<n;i++)  {
freq[s[i]-'a']++;
}
for(int i=0;i<26;i++)  {
if(freq[i])
{
cout<<char(i+'a')<<" "<<freq[i]<<"\n";
}
}``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````import java.util.LinkedHashMap;
import java.util.Map;

public class Test {
public static void main(String[] args) {
String test = "avarakedavra";
printCount(test);
}

private static void printCount(String test) {
Map<Character, Integer> lhm = new LinkedHashMap<>();
char[] characters = test.toCharArray();
for (Character a : characters) {
if(lhm.containsKey(a)){
lhm.put(a, lhm.get(a)+1);
}else{
lhm.put(a, 1);
}
}
for(Character a : lhm.keySet()){
System.out.println("("+a+", "+lhm.get(a)+")");
}

}``````

}

Comment hidden because of low score. Click to expand.
0
of 0 vote

void CountingOfCharacters(string str)
{
vector<sDataArray> data;
for(int i = 0; i < strlen(str.c_str()); i++)
{
char ch = str.at(i);
bool found = false;
std::vector<sDataArray>::iterator it = data.begin();
for (; it != data.end(); ++it)
{
if(it->ch == ch)
{
found = true;
it->count++;
}
}

if(!found)
{
sDataArray temp;
temp.ch = ch;
temp.count = 1;
data.insert(it,temp);
}

}

cout << "(" ;
for (std::vector<sDataArray>::iterator it = data.begin();it != data.end(); ++it)
{
cout << "(" << it->ch << "," << it->count << ")" ;
}
cout << ")";
}

Comment hidden because of low score. Click to expand.
0
of 0 vote

void CountingOfCharacters(string str){
vector<sDataArray> data;
for(int i = 0; i < strlen(str.c_str()); i++){
char ch = str.at(i);
bool found = false;
std::vector<sDataArray>::iterator it = data.begin();
for (; it != data.end(); ++it){
if(it->ch == ch){
found = true;
it->count++;}}

if(!found){
sDataArray temp;
temp.ch = ch;
temp.count = 1;
data.insert(it,temp);}}

cout << "(" ;
for (std::vector<sDataArray>::iterator it = data.begin();it != data.end(); ++it){
cout << "(" << it->ch << "," << it->count << ")" ;}
cout << ")";
}

Comment hidden because of low score. Click to expand.
0
of 0 vote

void CountingOfCharacters(string str){
vector<sDataArray> data;
for(int i = 0; i < strlen(str.c_str()); i++){
char ch = str.at(i);
bool found = false;
std::vector<sDataArray>::iterator it = data.begin();
for (; it != data.end(); ++it){
if(it->ch == ch){
found = true;
it->count++;}}
if(!found){
sDataArray temp;
temp.ch = ch;
temp.count = 1;
data.insert(it,temp);}}
cout << "(" ;
for (std::vector<sDataArray>::iterator it = data.begin();it != data.end(); ++it){
cout << "(" << it->ch << "," << it->count << ")" ;}
cout << ")";}

Comment hidden because of low score. Click to expand.
0
of 0 vote

Hi

Comment hidden because of low score. Click to expand.
0
of 0 vote
Comment hidden because of low score. Click to expand.
0
of 0 vote

Scala implementation:

``````def main(args: Array[String]) {
val s = "abbcdc"

println(s.groupBy(x => x).mapValues(_.length))
}``````

Comment hidden because of low score. Click to expand.
0

Or this:

``````def main(args: Array[String]) {
val s = "abbcdc"

val map = mutable.Map[Char, Int]()
s.toCharArray.foreach(c => map.update(c, map.getOrElse(c, 0) + 1))
println(map)
}``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````#include<stdio.h>

int  calculateFrequency(char* p)
{
int frequency[256];
int i= 0;
int firstItem=0;
bzero(frequency,256*sizeof(int));
for(i=0;i<strlen(p);i++)
{
frequency[p[i]]++;
}
printf("(");;
for(i=0;i<strlen(p);i++)
{
if(frequency[p[i]]!= 0)
{
if(firstItem==0)
{
printf("(%c,%d)",p[i],frequency[p[i]]);
firstItem=1;
}
else
{
printf(",(%c,%d)",p[i],frequency[p[i]]);
}
}
frequency[p[i]]=0;
}
printf(")");;
}
int main()
{
calculateFrequency("aaabbbDD");
}``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

int calculateFrequency(char* p)
{
int frequency[256];
int i= 0;
int firstItem=0;
bzero(frequency,256*sizeof(int));
for(i=0;i<strlen(p);i++)
{
frequency[p[i]]++;
}
printf("(");;
for(i=0;i<strlen(p);i++)
{
if(frequency[p[i]]!= 0)
{
if(firstItem==0)
{
printf("(%c,%d)",p[i],frequency[p[i]]);
firstItem=1;
}
else
{
printf(",(%c,%d)",p[i],frequency[p[i]]);
}
}
frequency[p[i]]=0;
}
printf(")");;
}
int main()
{
calculateFrequency("aaabbbDD");
}

Comment hidden because of low score. Click to expand.
0
of 0 vote

int calculateFrequency(char* p)
{
int frequency[256];
int i= 0;
int firstItem=0;
bzero(frequency,256*sizeof(int));
for(i=0;i<strlen(p);i++)
{
frequency[p[i]]++;
}
printf("(");;
for(i=0;i<strlen(p);i++)
{
if(frequency[p[i]]!= 0)
{
if(firstItem==0)
{
printf("(%c,%d)",p[i],frequency[p[i]]);
firstItem=1;
}
else
{
printf(",(%c,%d)",p[i],frequency[p[i]]);
}
}
frequency[p[i]]=0;
}
printf(")");;
}
int main()
{
calculateFrequency("aaabbbDD");
}

Comment hidden because of low score. Click to expand.
0
of 0 vote

int calculateFrequency(char* p)
{
int frequency[256];
int i= 0;
int firstItem=0;
bzero(frequency,256*sizeof(int));
for(i=0;i<strlen(p);i++)
{
frequency[p[i]]++;
}
printf("(");;
for(i=0;i<strlen(p);i++)
{
if(frequency[p[i]]!= 0)
{
if(firstItem==0)
{
printf("(%c,%d)",p[i],frequency[p[i]]);
firstItem=1;
}
else
{
printf(",(%c,%d)",p[i],frequency[p[i]]);
}
}
frequency[p[i]]=0;
}
printf(")");;
}
int main()
{
calculateFrequency("aaabbbDD");

}

Comment hidden because of low score. Click to expand.
0
of 0 vote

a = "Salesforce is the best company to work for"

hash = Hash.new(0)

a.downcase.split("").each do |letter|
hash["#{letter}"] += 1
end

hash.each do |key, value|
print "(#{key},#{value}),"
end

Comment hidden because of low score. Click to expand.
0
of 0 vote

public static List<Map<Character, Integer>> getFrequencyOfChars(String input) {
List<Map<Character, Integer>> list = new ArrayList<Map<Character, Integer>>();
Map<Character, Integer> map = new TreeMap<Character, Integer>();
int count;

for (int i = 0; i < input.length(); i++) {
count = 0;
for (int j = 0; j < input.length(); j++) {
if (input.charAt(i) == input.charAt(j)) {
count++;
}
}
map.put(input.charAt(i), count);
}
return list;
}

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````#include <cstdio>
#include <string.h>

//-----------------------------------------------------------------------------

#define NUM_OF_CHARS 0xFF

int main(int argc, char* argv[]) {
if (argc <= 1) {
perror("no input provided!");
return 1;
}

printf ("num of chars: %d\n", NUM_OF_CHARS);
char *input = argv[1];
unsigned short output[NUM_OF_CHARS] = {};
int count = 0;

do {
char ch = input[count++];
if ('\0' == ch)
break;
else
++output[(unsigned int)ch];

} while (true);

for (unsigned char i = 0; i < NUM_OF_CHARS; ++i)
{
if (((i >= 'a' && i <= 'z') || (i >= 'A' && i <= 'Z') || i == ' ')
&& output[(unsigned int)i] != 0)
printf ("(%c, %d), ", i, output[(unsigned int)i]);
}

return 0;
}``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````string s = "aaabcdfcc";
var chars = s.ToCharArray();

var dic = new Dictionary<char, string>();
for (int i = 0; i < chars.Length; i++)
{
if (dic.ContainsKey(chars[i]) == false)
{
dic.Add(chars[i], chars.Count(p => p == chars[i]).ToString());
}
}``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

string s = "aaabcdfcc";
var chars = s.ToCharArray();

var dic = new Dictionary<char, string>();
for (int i = 0; i < chars.Length; i++)
{
if (dic.ContainsKey(chars[i]) == false)
{
dic.Add(chars[i], chars.Count(p => p == chars[i]).ToString());
}
}

Comment hidden because of low score. Click to expand.
0
of 0 vote

public static void combo(String str){

char[] array=str.toCharArray();

HashMap<Character,Integer> map=new HashMap<Character,Integer>();
for(int i=0;i<array.length-1;i++){
if(!map.containsKey(array[i])){
map.put(array[i], 1);
}
else
map.put(array[i],map.get(array[i])+1);
}

for(Character a : map.keySet()){
System.out.println(a +" && "+ map.get(a));
}
}

Comment hidden because of low score. Click to expand.
0
of 0 vote

C++ Solution

``````#include<iostream>
#include<map>
#include<vector>

using namespace std;
#if 0
void countLetters(string &in)
{
map<char,unsigned int> countMap;
for (unsigned int i = 0; i < in.size(); i++) {
countMap[in[i]] ++;
}
for (map<char, unsigned int>::iterator it = countMap.begin(); it != countMap.end(); it++) {
cout << "(" << (*it).first << "," << (*it).second << ") - ";
}
}
#endif

void countLetters(string &in)
{
vector<unsigned int> hashTable(255, 0);
for (unsigned int i = 0; i < in.size(); i++) {
hashTable[in[i]] ++ ;
}
for (int i = 0; i < 255; i++) {
if (hashTable[i] > 0) {
cout << "(" << static_cast<unsigned char>(i) << "," << hashTable[i] << ") - ";
}
}
}
int main ()
{
string str = "abbcccdddeeeea";
countLetters(str);
return 0;``````

}

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````using System;
using System.Collections.Generic;

namespace FindCharacterFrequency
{
class Program
{
static void Main(string[] args)
{
var input = "abbcdc";
var freq = GetCharacterFrequency(input);

ToString(freq);

}

public static Dictionary<char, int> GetCharacterFrequency(string input)
{
if (input == null) return null;

if (input.Length == 0) return null;

if(input.Length == 1)
{
var dict = new Dictionary<char, int>();
return dict;
}

var charArray = input.ToCharArray();
var freqList = new Dictionary<char, int>();
foreach (var ch in charArray)
{
if (freqList.ContainsKey(ch))
{
freqList[ch]++;
}
else
{
}
}
return freqList;
}

public static void ToString(Dictionary<char, int> freq)
{
foreach (var item in freq)
{
Console.WriteLine("({0},{1})", item.Key, item.Value);
}
}
}
}``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````using System;
using System.Collections.Generic;

namespace FindCharacterFrequency
{
class Program
{
static void Main(string[] args)
{
var input = "abbcdc";
var freq = GetCharacterFrequency(input);

ToString(freq);

}

public static Dictionary<char, int> GetCharacterFrequency(string input)
{
if (input == null) return null;

if (input.Length == 0) return null;

if(input.Length == 1)
{
var dict = new Dictionary<char, int>();
return dict;
}

var charArray = input.ToCharArray();
var freqList = new Dictionary<char, int>();
foreach (var ch in charArray)
{
if (freqList.ContainsKey(ch))
{
freqList[ch]++;
}
else
{
}
}
return freqList;
}

public static void ToString(Dictionary<char, int> freq)
{
foreach (var item in freq)
{
Console.WriteLine("({0},{1})", item.Key, item.Value);
}
}
}
}``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

stringChars = list('abbcdc')
list({key: stringChars.count(key) for key in stringChars}.items())

Output: [('b', 2), ('c', 2), ('a', 1), ('d', 1)]
Aka: Why I like using python :p

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````stringChars = list('abbcdc')
print(list({key: stringChars.count(key) for key in stringChars}.items()))``````

Output: [('b', 2), ('c', 2), ('a', 1), ('d', 1)]
Aka Why I Like Python.

Comment hidden because of low score. Click to expand.
0

order n^2 and out of order result!
Aka why you don't know algorithms

Comment hidden because of low score. Click to expand.
0
of 0 vote

HashMap<Character, Integer> map = new HashMap<Character, Integer>();
String s = "java";
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
Integer val = map.get(new Character(c));
if (val != null) {
map.put(c, new Integer(val + 1));
} else {
map.put(c, 1);
}
}
System.out.println(map);

Comment hidden because of low score. Click to expand.
0
of 0 vote

HashMap<Character, Integer> map = new HashMap<Character, Integer>();
String s = "java";
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
Integer val = map.get(new Character(c));
if (val != null) {
map.put(c, new Integer(val + 1));
} else {
map.put(c, 1);
}
}
System.out.println(map);

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````/*
given a string, calculate the frequency of characters, output the array with the letter and frequency.
(such as: for “abbcdc”, the output should be (a,1),(b,2),(c,2),(d,1))
*/

package algorithm;

public class CharFrequency {

private String str = "abbcdcb";
private char[] charArr = str.toCharArray();

public void countFreq(char[] arr){
int count = 0;
for(int i = 0; i<=arr.length-1; i++){
count = 0;
//char tempChar = arr[i];
for(int j = 0; j <= arr.length-1; j++){
if(arr[i] == arr[j]){
count++;
}

}

System.out.print(" (" + arr[i] + "," + count + ")");
}
}

public static void main(String[] args) {
CharFrequency obj = new CharFrequency();
obj.countFreq(obj.charArr);

}

}``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````void fun2(char *str){
int *arr = (int*)calloc(sizeof(int)* 128, 1);
while (*str)
arr[*str++]++;
for (int i = 0; i < 128; i++)
if (arr[i] != 0)
printf("(%c %d)\n", i, arr[i]);
}``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````class FrequencyCalculator {
public static void calculator(String str) {
int[] ch = new int[26];
for (int i = 0; i < str.length(); i++) {
ch[str.charAt(i) - 'a']++;
}

for (int i = 0; i < ch.length; i++) {
if (ch[i] > 0) {
System.out.print("(" + (char) (i + 'a') + ", " + ch[i] + "),");
}
}
System.out.println("");
}
}

public class CalculateFrequency {

public static void main(String[] args) {
FrequencyCalculator.calculator("abbcdc");
}
}``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````class FrequencyCalculator {
public static void calculator(String str) {
int[] ch = new int[26];
for (int i = 0; i < str.length(); i++) {
ch[str.charAt(i) - 'a']++;
}

for (int i = 0; i < ch.length; i++) {
if (ch[i] > 0) {
System.out.print("(" + (char) (i + 'a') + ", " + ch[i] + "),");
}
}
System.out.println("");
}
}

public class CalculateFrequency {

public static void main(String[] args) {
FrequencyCalculator.calculator("abbcdc");
}
}``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````public static void main (String[] args){
int[] counter = new int[52];

String input = "AAbbbccccddeegg";

char[] inputArray = input.toCharArray();

for (char c : inputArray){
int index = ((int) c) - ((int) 'A');
counter[index]++;
}

for (int i =0; i< counter.length; i++){
if (counter[i] > 0){
System.out.print("(" + ((char) ('A' + i)) + "," + counter[i] + ") ");
}
System.out.flush();
}

}``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

package prudhvi;

import java.util.HashMap;
import java.util.HashSet;

public class Apple {

public static void main(String[] args) {
HashMap<Character,Integer> hs=new HashMap<>();
String s="abbbcdddc";
int count=0;
for(int i=0;i<s.length();i++)
{
count=0;
for(int j=0;j<s.length();j++)
{
if(s.charAt(i)==s.charAt(j))
{
count++;
}
}
hs.put(s.charAt(i),count);

}
System.out.println(hs);
}
}

Comment hidden because of low score. Click to expand.
0
of 0 vote

public static void main(String[] args) {
// TODO Auto-generated method stub
String str = "abbcdcab";
for ( int i = 0; i<str.length(); i++){
char chr = str.charAt(i);
int flag = 0;
for(int k =0; k<i; k++){
if (str.charAt(k)==chr)
flag = 1;
}
if (flag ==0){
int c = 1;
for(int j=i+1; j<str.length(); j++){
if(str.charAt(j)==chr){
c = c+1;
}
}
System.out.print("("+chr+","+c+")"+" ");

}
}

}

Comment hidden because of low score. Click to expand.
0
of 0 vote

import java.util.Map;
import java.util.Scanner;

public class MAIN {

public static void main(String[] args) {

String str1= new String() ;
Scanner scn= new Scanner(System.in);
System.out.println("Enter String To calculate");
str1=scn.nextLine();
printArrayFrq(str1);

}

public static void printArrayFrq(String test)
{
char ch[]=test.toCharArray();
for(Character a: ch)
{
if(arr.containsKey(a))
{

arr.put(a, arr.get(a)+1);

}
else
{
arr.put(a,1);

}
}

for(Character a:arr.keySet())
{

System.out.println("("+a+","+arr.get(a)+")");

}
}

}

Comment hidden because of low score. Click to expand.
0
of 0 vote

import java.util.Map;
import java.util.Scanner;

public class MAIN {

public static void main(String[] args) {

String str1 = new String();
Scanner scn = new Scanner(System.in);
System.out.println("Enter String To calculate");
str1 = scn.nextLine();
printArrayFrq(str1);

}

public static void printArrayFrq(String test) {
char ch[] = test.toCharArray();
Map<Character, Integer> arr = new LinkedHashMap<>();
for (Character a : ch) {
if (arr.containsKey(a)) {

arr.put(a, arr.get(a) + 1);

} else {
arr.put(a, 1);

}
}

for (Character a : arr.keySet()) {

System.out.println("(" + a + "," + arr.get(a) + ")");

}
}

}

Comment hidden because of low score. Click to expand.
0
of 0 vote

import java.util.Map;
import java.util.Scanner;

public class MAIN {
public static void main(String[] args) {
String str1 = new String();
Scanner scn = new Scanner(System.in);
System.out.println("Enter String To calculate");
str1 = scn.nextLine();
printArrayFrq(str1);
}
public static void printArrayFrq(String test) {
char ch[] = test.toCharArray();
Map<Character, Integer> arr = new LinkedHashMap<>();
for (Character a : ch) {
if (arr.containsKey(a)) {
arr.put(a, arr.get(a) + 1);
} else {
arr.put(a, 1);
}}
for (Character a : arr.keySet()) {
System.out.println("(" + a + "," + arr.get(a) + ")");
}}}

Comment hidden because of low score. Click to expand.
0
of 0 vote

import java.util.Map;
import java.util.Scanner;
public class MAIN {
public static void main(String[] args) {
String str1 = new String();
Scanner scn = new Scanner(System.in);
System.out.println("Enter String To calculate");
str1 = scn.nextLine();
printArrayFrq(str1);
}
public static void printArrayFrq(String test) {
char ch[] = test.toCharArray();
Map<Character, Integer> arr = new LinkedHashMap<>();
for (Character a : ch) {
if (arr.containsKey(a)) {
arr.put(a, arr.get(a) + 1);
} else {
arr.put(a, 1);}}
for (Character a : arr.keySet()) {
System.out.println("(" + a + "," + arr.get(a) + ")");}}}

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````public static void main(String[] args) {
String a = "abbcdc";
HashMap<Character,Integer> result = new HashMap<Character, Integer>();
char[] ch = a.toCharArray();
for (int i = 0; i < ch.length; i++) {
int originalSize = a.length();
int trimmedSize = a.replace(String.valueOf(ch[i]), "").length();
result.put(ch[i],originalSize-trimmedSize);
}
System.out.println(result);
}``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````public static void main(String[] args) {
String s = "abbcdc";
//Output should be like (a,1), (b,2), (c,2), (d,1)
for(int i=0; i<s.length(); i++) {
if(lhm.containsKey(s.charAt(i))) {
lhm.put(s.charAt(i), lhm.get(s.charAt(i)) + 1);
} else {
lhm.put(s.charAt(i), 1);
}
}
Set<Character> keySet = lhm.keySet();
String finalVal = "";
for(Character ch:keySet) {
finalVal += "(" + ch + "," + lhm.get(ch) + "),";
}
System.out.println(finalVal.substring(0, finalVal.length()-1));
}``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````public static void main(String[] args) {
String s = "abbcdc";
//Output should be like (a,1), (b,2), (c,2), (d,1)
for(int i=0; i<s.length(); i++) {
if(lhm.containsKey(s.charAt(i))) {
lhm.put(s.charAt(i), lhm.get(s.charAt(i)) + 1);
} else {
lhm.put(s.charAt(i), 1);
}
}
Set<Character> keySet = lhm.keySet();
String finalVal = "";
for(Character ch:keySet) {
finalVal += "(" + ch + "," + lhm.get(ch) + "),";
}
System.out.println(finalVal.substring(0, finalVal.length()-1));
}``````

Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

### Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

### Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.