String Data Structure
Learn more about String in DSA Self Paced Course
Practice Problems on String
What is String?
Strings are defined as an array of characters. The difference between a character array and a string is the string is terminated with a special character ‘\0’.
Below are some examples of strings:
“geeks”, “for”, “geeks”, “GeeksforGeeks”, “Geeks for Geeks”, “123Geeks”, “@123 Geeks”
How String is represented in Memory?
In C, a string can be referred to either using a character pointer or as a character array. When strings are declared as character arrays, they are stored like other types of arrays in C. For example, if str[] is an auto variable then the string is stored in the stack segment, if it’s a global or static variable then stored in the data segment, etc.
Topics:
- Searching For Characters and Substring in a String
- Program to reverse a string (Iterative and Recursive)
- Left Rotation and Right Rotation of a String
- Sort string of characters
- Print the frequency of each character in Alphabetical order
- Swap characters in a String
- C program to find the length of a string
- How to insert characters in a string at a certain position?
- Program to check if two strings are same or not
- Concatenating Two Strings
- Remove all occurrences of a character in a string
- Change if all bits can be made same by single flip
- Number of flips to make binary string alternate
- Binary representation of next number
- Min flips of continuous characters to make all characters same in a string
- Generate all binary strings without consecutive 1’s
- Find i’th Index character in a binary string obtained after n iterations
- Generate n-bit Gray Codes
- Program to print all substrings of a given string
- Print all subsequences of a string
- Count Distinct Subsequences
- Count distinct occurrences as a subsequence
- Longest Common Subsequence
- Shortest Superstring Problem
- Printing Shortest Common Supersequence
- Shortest Common Supersequence
- Longest Repeating Subsequence
- Longest Palindromic Subsequence
- Longest Palindromic Substring using Dynamic Programming
- C Program to Check if a Given String is Palindrome
- Check if a given string is a rotation of a palindrome
- Check if characters of a given string can be rearranged to form a palindrome
- Online algorithm for checking palindrome in a stream
- Print all palindromic partitions of a string
- Minimum characters to be added at front to make string palindrome
- Make largest palindrome by changing at most K-digits
- Minimum number of deletions to make a string palindrome
- Minimum insertions to form a palindrome with permutations allowed
- Naive algorithm for Pattern Searching
- KMP Algorithm for Pattern Searching
- Z algorithm
- Search a Word in a 2D Grid of characters
- Wildcard Pattern Matching
- Aho-Corasick Algorithm
- Find all strings that match specific pattern in a dictionary
- Check if string follows order of characters defined by a pattern or not
- Easy:
- Count strings with consecutive 1’s
- Generate all binary strings from given pattern
- Add n binary strings
- Divide large number represented as string
- Program to find Smallest and Largest Word in a String
- Count number of equal pairs in a string
- Camel case of a given sentence
- Second most repeated word in a sequence
- Print all possible strings that can be made by placing spaces
- Check if all levels of two trees are anagrams or not
- Medium:
- K’th Non-repeating Character
- Queries for characters in a repeated string
- URLify a given string (Replace spaces is %20)
- Count of total anagram substrings
- Count number of binary strings without consecutive 1’s
- Lexicographically next string
- Check if given string can be split into four distinct strings
- Word Break Problem
- Check for balanced parentheses in an expression | O(1) space
- Length of Longest Balanced Subsequence
- Minimum Swaps for Bracket Balancing
- Convert a sentence into its equivalent mobile numeric keypad sequence
- Burrows – Wheeler Data Transform Algorithm
- Form minimum number from given sequence
- Print shortest path to print a string on screen
- Mirror characters of a string
- Hard:
