Question d’entretien chez Entain India

Problem: Given a string which has some repeated characters. Write a Java program to identify the character and print the number of occurrences

Réponses aux questions d'entretien

Utilisateur anonyme

12 févr. 2021

1. Sort the string in ascending order and compare the character array i with i-1, if its same, store it in a map. Time O(nlgn) 2. Use a map and put the values to the map. If getting a value to map is not null, its a duplicate character and maintain count in map values. Time :O(n) 3. Without using collections.Create an int array of size 26, where 0 denotes a and 25 denotes z. Increment the value by 1 when we get a character. Again go for a for loop to find the count of each character, if its greater than 0, print values of character and count. Time :O(n+k) ,k=26

1

Utilisateur anonyme

11 févr. 2021

Implement the pseudo java code and shown to the interviewer