String – Interview Questions and Practice Problems

A string is traditionally a sequence of characters, either as a literal constant or as some kind of variable. The latter may allow its elements to be mutated and the length changed, or it may be fixed (after creation).

A string is generally understood as a data type and is often implemented as an array of bytes (or words) that stores a sequence of elements, typically characters. String datatypes have historically allocated one byte per character. In C, the length of a string can be stored implicitly by using a special terminating character; often this is the null character (NUL), which has all bits zero.

 
Following is the list of commonly asked string interview questions:

  1. Check if a string is a rotated palindrome or notMedium
  2. Longest Palindromic Substring ProblemMedium
  3. Check if a repeated subsequence is present in a string or notHard
  4. Check if strings can be derived from each other by circularly rotating themEasy
  5. Check if a set of moves is circular or notMedium
  6. Convert a number into a corresponding excel column nameMedium
  7. Determine whether two strings are anagram or notEasy
  8. Find all interleaving of given stringsEasy
  9. Isomorphic StringsMedium
  10. Find all possible palindromic substrings of a stringHard
  11. Find all possible combinations of words formed from the mobile keypadHard
  12. Find all possible combinations by replacing given digits with characters of the corresponding listHard
  13. >Find all words that follow the same order of characters as given patternMedium
  14. Group anagrams together from a list of wordsMedium
  15. Find minimum operations required to transform a string into another stringHard
  16. Determine whether a string can be transformed into another string in a single editMedium
  17. In-place remove all occurrences of AB and C from a stringEasy
  18. Find the longest even-length palindromic sum substring of a stringMedium
  19. Print string in the zigzag form in k rowsMedium
  20. Run Length Encoding (RLE) Data Compression AlgorithmEasy
  21. Find the longest substring of a string containing k distinct charactersHard
  22. Find all palindromic permutations of a stringMedium
  23. Find all substrings of a string that are a permutation of another stringMedium
  24. Find the longest substring of a string containing distinct charactersMedium
  25. Find all permutations of a string – C++, Java, PythonHard
  26. Iterative approach to finding permutations of a stringHard
  27. Find all lexicographically next permutations of a string sorted in ascending orderHard
  28. Lexicographically Minimal String RotationMedium
  29. Find all strings of a given length containing balanced parenthesesMedium
  30. Find all combinations of non-overlapping substrings of a stringMedium
  31. Determine whether a string is a palindrome or notEasy
  32. Find the minimum number of inversions needed to make an expression balancedMedium
  33. Construct the longest palindrome by shuffling or deleting characters from a stringMedium
  34. Print all combinations of phrases formed by picking words from each of the given listsMedium
  35. Break a string into all possible combinations of non-overlapping substringsMedium
  36. Remove all extra spaces from a stringMedium
  37. Remove adjacent duplicate characters from a stringEasy
  38. Find the first non-repeating character in a string by doing only one traversal of itMedium
  39. Find all n-digit strictly increasing numbers (Bottom-up and Top-down approach)Medium
  40. Find all n-digit binary numbers having more 1’s than 0’s for any prefixMedium
  41. Find all n-digit numbers with a given sum of digitsHard
  42. Find all n-digit binary numbers with k-bits set where k ranges from 1 to nHard
  43. Find all n-digit binary numbers with an equal sum of bits in their two halvesHard
  44. Find all n-digit numbers with equal sum of digits at even and odd indicesHard
  45. Find all lexicographic permutations of a stringHard
  46. Lexicographic rank of a stringHard
  47. Find all lexicographically previous permutations of a string sorted in descending orderHard
  48. Replace all non-overlapping occurrences of a patternMedium
  49. Find all substrings containing exactly k distinct charactersMedium
  50. Introduction to Pattern MatchingBeginner
  51. Implementation of KMP AlgorithmHard
  52. Reverse a string using recursionEasy
  53. Determine whether the characters of a string follow a specified order or notMedium
  54. In-place remove all adjacent duplicates from a stringMedium
  55. Check if a sentence is syntactically correct or notMedium
  56. Number to word conversionHard
  57. Implement strstr function in JavaEasy
  58. Shortest Superstring ProblemHard
  59. Find the shortest route in a device to construct a given stringMedium
  60. Find the minimum number possible by doing at-most k swapsMedium
  61. Determine whether a string matches with a given patternHard
  62. Find all occurrences of the given string in a character matrixHard
  63. Difference between Subarray, Subsequence, and SubsetBeginner
  64. Check if an expression is balanced or notEasy
  65. Find duplicate parenthesis in an expressionMedium
  66. Evaluate a postfix expressionEasy
  67. Decode a given sequence to construct a minimum number without repeated digitsHard
  68. Convert an infix expression into a postfix expressionMedium
  69. Reverse a string using a stack data structureEasy
  70. Find all binary strings that can be formed from a wildcard patternMedium
  71. Find the length of the longest balanced parenthesis in a stringHard
  72. Reverse text without reversing individual wordsMedium
  73. Reverse a string without using recursionEasy
  74. Combinations of words formed by replacing given numbers with corresponding alphabetsHard
  75. Longest Common Prefix (LCP) ProblemEasy
  76. Longest Common Subsequence ProblemMedium
  77. Longest Common Subsequence (LCS) | Space optimized versionMedium
  78. Longest Common Subsequence of k–sequencesMedium
  79. Longest Common Subsequence | Finding all LCSHard
  80. Longest Common Substring ProblemMedium
  81. Longest Palindromic Subsequence using Dynamic ProgrammingMedium
  82. Longest Repeated Subsequence ProblemMedium
  83. Implement Diff UtilityMedium
  84. Shortest Common Supersequence ProblemMedium
  85. Shortest Common Supersequence | Finding all SCSHard
  86. Shortest Common Supersequence Problem using LCSHard
  87. The Levenshtein distance (Edit distance) ProblemMedium
  88. Count the number of times a pattern appears in a given string as a subsequenceHard
  89. Word Break Problem – Dynamic ProgrammingHard
  90. Check if a string is k–palindrome or notHard
  91. Wildcard Pattern MatchingHard
  92. Find the minimum number of deletions required to convert a string into a palindromeMedium
  93. Find minimum cuts needed for the palindromic partition of a stringHard
  94. Check if a string matches with the given wildcard patternHard
  95. Check if a string is interleaving of two other given stringsMedium
  96. Find correct order of alphabets in a given dictionary of ancient originHard
  97. Find first k non-repeating characters in a string in a single traversalMedium
  98. Check if a linked list of strings is palindromicEasy
  99. Generate binary numbers between 1 to n using a queueEasy
  100. Longest Common Prefix in a given set of strings (using Trie)Medium
  101. Lexicographic sorting of a given set of keysMedium
  102. Find the maximum occurring word in a given set of stringsEasy
  103. Find first k maximum occurring words in a given set of stringsMedium
  104. Word Break Problem – Using Trie Data StructureMedium
  105. Find all words matching a pattern in the given dictionaryMedium
  106. Find the shortest unique prefix for every word in an arrayMedium

Rate this post

Average rating 4.82/5. Vote count: 56

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

Tell us how we can improve this post?

Thanks for reading.

To share your code in the comments, please use our online compiler that supports C, C++, Java, Python, JavaScript, C#, PHP, and many more popular programming languages.

Like us? Refer us to your friends and support our growth. Happy coding :)


guest
0 Comments
Inline Feedbacks
View all comments
Do NOT follow this link or you will be banned from the site!