Phase 5 - Category 5: Advanced String Logic
Solve complex string problems with advanced logic.
14 programs · open one, then the next
Start with Check Anagram- 01Check AnagramAdvancedCheck anagrams by normalizing case and ordinary spaces. Students compare sorted character lists and retain duplicate counts, punctuation, and other whitespace.Open example →py# Take two strings s1 = input("Enter first string: ").lower().replace(" ", "") s2 = input("Enter second string: ").lower().replace(" ", "")
- 02Check if Substring ExistsIntermediateTest whether one string occurs inside another with membership. Students preserve substring order, see case-sensitive matching, and examine the empty-pattern rule.Open example →py# Take two strings s1 = input("Enter first string: ") s2 = input("Enter second string: ")
- 03Count Substring OccurrencesIntermediateCount substring occurrences with Python str.count. Students test absent and empty patterns and distinguish nonoverlapping matches from overlapping positions.Open example →py# Take two strings s = input("Enter string: ") substring = input("Enter substring: ")
- 04Extract Numbers from StringAdvancedExtract runs of digit characters as integers from mixed text. Students buffer adjacent digits, flush on separators, and handle a number without a separator.Open example →py# Take string input s = input("Enter a string: ") # Extract numbers
- 05Sum of Numbers in StringAdvancedSum whole-number digit runs embedded in text with Python. Students buffer adjacent digits, add completed values, and distinguish numbers from digit characters.Open example →py# Take string input s = input("Enter a string: ") # Extract and sum numbers
- 06Check if All Characters SameIntermediateCheck whether all string positions contain the same character. Students use Python set size while treating case, spaces, and empty input as distinct concerns.Open example →py# Take string input s = input("Enter a string: ") # Check if all same
- 07Remove Adjacent DuplicatesAdvancedCollapse adjacent duplicate characters with Python. Students track the previous character, keep separated repeats, and distinguish runs from global duplicates.Open example →py# Take string input s = input("Enter a string: ") # Remove adjacent duplicates
- 08Find First Non-Repeating CharacterAdvancedFind the earliest character that occurs exactly once with Python. Students count first, scan order second, and stop at the first frequency-one character.Open example →py# Take string input s = input("Enter a string: ") # Find first non-repeating
- 09Find Most Frequent CharacterAdvancedFind the most frequent nonspace character. Students build a frequency map, select by count, and understand the first-seen rule when maximum counts tie.Open example →py# Take string input s = input("Enter a string: ") # Count frequency
- 10Check String RotationAdvancedCheck whether one string is a rotation of another with Python. Students require equal lengths and search the doubled first string for a wrapped arrangement.Open example →py# Take two strings s1 = input("Enter first string: ") s2 = input("Enter second string: ")
- 11Longest Common PrefixAdvancedFind the longest shared starting text across strings. Students shrink a candidate prefix until each response starts with it and handle an empty input collection.Open example →py# Take strings n = int(input("Enter number of strings: ")) strings = [] for i in range(n):
- 12String CompressionAdvancedEncode adjacent character runs as character-count pairs. Students reset a run counter, flush completed runs, and include the final run after traversal.Open example →py# Take string s = input("Enter string: ") # Compress
- 13Valid Parentheses CheckAdvancedValidate nested brackets with a Python stack. Students push openers, match the latest one first, and reject early closers or openings left at the end.Open example →py# Take string s = input("Enter string with parentheses: ") # Check balance
- 14Reverse Words in StringAdvancedReorder whole words without reversing their letters. Students contrast blue red with der eulb and trace whitespace normalization in split, reverse, and join.Open example →py# Take string s = input("Enter string: ") # Reverse words