Friday, September 20, 2024

String coding questioon

 

  1. How do you reverse a given string in place? (solution)
  2. How do you print duplicate characters from a string? (solution)
  3. How do you check if two strings are anagrams of each other? (solution)
  4. How do you find all the permutations of a string? (solution)
  5. How can a given string be reversed using recursion? (solution)
  6. How do you check if a string contains only digits? (solution)
  7. How do you find duplicate characters in a given string? (solution)
  8. How do you count a number of vowels and consonants in a given string? (solution)
  9. How do you count the occurrence of a given character in a string? (solution)
  10. How do you print the first non-repeated character from a string? (solution)
  11. How do you convert a given String into int like the atoi()? (solution)
  12. How do you reverse words in a given sentence without using any library method? (solution)
  13. How do you check if two strings are a rotation of each other? (solution)
  14. How do you check if a given string is a palindrome? (solution)
  15. How do you find the length of the longest substring without repeating characters? (solution)
  16. Given string str, How do you find the longest palindromic substring in str? (solution)
  17. How to convert a byte array to String? (solution)
  18. how to remove the duplicate character from String? (solution)
  19. How to find the maximum occurring character in given String? (solution)
  20. How do you remove a given character from String? (solution)

HashMap coding and interview question


2) How do you add key-value pairs to HashMap?->using add() or addAll() method
3) How do you add given key-value pair to HashMap if and only if it is not present in the HashMap?
4) How do you retrieve a value associated with a given key from the HashMap?
5) How do you check whether a particular key/value exist in a HashMap?
6) How do you find out the number of key-value mappings present in a HashMap?
7) How do you remove all key-value pairs from a HashMap? OR How do you clear the HashMap for reuse?
8) How do you retrieve all keys present in a HashMap?
9) How do you retrieve all the values present in a HashMap?
10) How do you retrieve all key-value pairs present in a HashMap?
11) How do you remove a key-value pair from the HashMap?
12) How do you remove a key-value pair from a HashMap if and only if the specified key is currently mapped to given value?
13) How do you replace a value associated with a given key in the HashMap?
14) How do you replace a value associated with the given key if and only if it is currently mapped to given value?
15) How do you get synchronized HashMap in java?

String coding questioon

  How do you reverse a given string in place? ( solution ) How do you print duplicate characters from a string? ( solution ) How do you chec...