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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly