Interview Question: Reduced String
A reduced string is a string with all repeating letters condensed into one. The exercise was writing a function that compares two strings and returns true if their reduced string is the same.
What I did for this was…
- have a pointer to the start of each string
- compare the two letters
- if they’re not the same, return false
- if only one was terminated and the other hasn’t, return false
And that’s it. Better ideas? Corrections (I might have mistyped, it’s early)?
Posted in No Category, Programming, Thinking Out Loud by Eran with 2 comments.
no better ideas
but numbering is 1.2.1., should be 1.2.3.
The 1 is suppose to be a sub section of the 2. The formatting went screwy.