Arrays and Strings Flashcards
How to solve problems involving arrays and strings
1
Q
isUnique - Are all characters in a string unique
A
Make an array of 128 booleans (ASCII) and set for each char value
2
Q
Given two strings, design a method to tell if one is a permutation of the other
A
Sort the strings and return if they’re equal
3
Q
Determine if a string is a permutation of a palindrome
A
Put each character in a hashtable with character count association, then loop through hash table making sure that no more than 1 character contains an odd number of occurrences.
4
Q
Determine if two strings are one change away from being equal to each other
A
Check the length of each string to determine which operation we’ll need to use (insert/replace)