Practice Problems on String Data Structure

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.

Below is the list of commonly asked string interview questions –

  1. Check if given string is a rotated palindrome or not
  2. Longest Palindromic Substring (Non-DP Space Optimized Solution)
  3. Check if repeated subsequence is present in the string or not
  4. Check if strings can be derived from each other by circularly rotating them
  5. Check if given set of moves is circular or not
  6. Convert given number into corresponding excel column name
  7. Determine if two strings are anagram or not
  8. Find all binary strings that can be formed from given wildcard pattern
  9. Find all interleavings of given strings
  10. Isomorphic Strings
  11. Find all possible palindromic substrings in a string
  12. Find all possible combinations of words formed from mobile keypad
  13. Find all possible combinations by replacing given digits with characters of the corresponding list
  14. Find all words from given list that follows same order of characters as given pattern
  15. Find first k non-repeating characters in a string in single traversal
  16. Group anagrams together from given list of words
  17. Introduction to Pattern Matching
  18. Inplace remove all occurrences of ‘AB’ and ‘C’ from the string
  19. Longest even length palindromic sum substring
  20. Print string in zig-zag form in k rows
  21. Reverse given text without reversing the individual words
  22. Run Length Encoding (RLE) data compression algorithm
  23. Validate an IP address
  24. Find the longest substring of given string containing k distinct characters
  25. Find all palindromic permutations of a string
  26. Find all substrings of a string that are permutation of a given string
  27. Find the longest substring of given string containing all distinct characters
  28. Find all Permutations of a given string
  29. Iterative Approach to find Permutations of a String
  30. Generate all Permutations of a String in Java | Recursive & Iterative
  31. Find all lexicographically next permutations of a string sorted in ascending order
  32. Find Lexicographically minimal string rotation
  33. Find all strings of given length containing balanced parentheses
  34. Find all N-digit strictly increasing numbers (Bottom-Up and Top-Down Approach)
  35. Find all N-digit binary numbers having more 1’s than 0’s for any prefix
  36. Find all N-digit numbers with given sum of digits
  37. Find all N-digit binary numbers with k-bits set where k ranges from 1 to N
  38. Generate binary numbers between 1 to N
  39. Find all combinations of non-overlapping substrings of a string
  40. Check if given sentence is syntactically correct or not
  41. Calculate rank of given string among all its lexicographically sorted permutations
  42. Find all Lexicographic Permutations of a String
  43. Find all N-digit binary numbers with equal sum of bits in its two halves
  44. Check if given string is interleaving of two other given strings
  45. Difference between Subarray, Subsequence and Subset
  46. std::next_permutation | Overview & Implementation in C++
  47. std::prev_permutation | Overview & Implementation in C++
  48. Implementation of KMP Algorithm
  49. Reverse String without using Recursion
  50. Reverse given string using Recursion
  51. Reverse a String in Java in 10 different ways
  52. Determine if a given string is palindrome or not
  53. In-place remove all adjacent duplicates from the given string
  54. Find the minimum number of inversions needed to make the given expression balanced
  55. Replace all non-overlapping occurrences of the pattern
  56. Construct the longest palindrome by shuffling or deleting characters from a string
  57. Determine if characters of a String follows a specified order or not
  58. Print all combinations of phrases that can be formed by picking words from each of given lists
  59. Remove all extra spaces from a string
  60. Break a string into all possible combinations of non-overlapping substrings
  61. Remove adjacent duplicate characters from a string
  62. Find first non-repeating character in a string by doing only one traversal of it
  63. Find all N-digit numbers with equal sum of digits at even and odd index
  64. Combinations of words formed by replacing given numbers with corresponding alphabets
  65. Word Break Problem
  66. Wildcard Pattern Matching
  67. Count number of times a pattern appears in given string as a subsequence
  68. The Levenshtein distance (Edit distance) problem
  69. Longest Common Subsequence | Introduction & LCS Length
  70. Longest Common Subsequence | Space optimized version
  71. Longest Common Subsequence of K-sequences
  72. Longest Common Subsequence | Finding all LCS
  73. Longest Repeated Subsequence problem
  74. Longest Palindromic Subsequence using Dynamic Programming
  75. Longest Common Substring problem
  76. Shortest Common Supersequence | Introduction & SCS Length
  77. Shortest Common Supersequence | Finding all SCS
  78. Shortest Common Supersequence | Using LCS
  79. Implement Diff Utility
  80. Word Break Problem | Using Trie Data Structure
  81. Find minimum cuts needed for palindromic partition of a string
  82. Check if a string is K-Palindrome or not
  83. Find shortest route in a device to construct the given string
  84. Find minimum number possible by doing at-most K swaps
  85. Determine if a pattern matches with a string or not


Thank you for being with us. 🙂


Leave a Reply

Notify of