r/dailyprogrammer • u/nint22 1 2 • Jun 10 '13
[Easy] Longest Two-Character Sub-String
(Easy): Longest Two-Character Sub-String
This programming challenge is a classic interview question for software engineers: given a string, find the longest sub-string that contains, at most, two characters.
Author: /u/Regul
Formal Inputs & Outputs
Input Description
Through standard console input, you will be given a string to search, which only contains lower-case alphabet letters.
Output Description
Simply print the longest sub-string of the given string that contains, at most, two unique characters. If you find multiple sub-strings that match the description, print the last sub-string (furthest to the right).
Sample Inputs & Outputs
Sample Inputs
abbccc
abcabcabcabccc
qwertyytrewqSample Outputs
bbccc
bccc
tyyt
View all comments
Show parent comment
21
u/Geldan Jun 10 '13
I'm not certain why you would suggest that RetroSpock never purchase a book. I, for one, look back fondly at that moment, when I was 13 and reading Jamsa's C/C++ Bible, where I realized what a linked list was and why pointers were important. To this day, gainfully employed as a developer, I, and my coworkers, constantly purchase and read programming books.
Yes, there are plenty of resources on the web and they are great. Sometimes, however, books are better.