### Hints for SRM 611, D2, 250-pointer (InterestingNumber)

### James S. Plank

Tue Mar 4 18:34:05 EST 2014

Problem Statement.

I was surprised to see that only 52 percent of the Topcoders got this one
correct. It doesn't feel tricky to me.
As always, the key is to think precisely about how you are testing the string. You
want to do the following for each digit from '0' through '9':

- Count the occurrences of the digit. If it is zero, then you're fine and
can move onto the next digit.
- If it is non-zero, but not equal to two, then the number is not interesting.
- If it is equal to two, then you need to look at the indices of the digit, and
test their difference. If it is correct, then move onto the next digit.
Otherwise, the number is not interesting. Now, I want you to think about what "correct" means.
Do a few examples -- the pattern should be pretty clear.