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
qwertyytrewq
Sample Outputs
bbccc
bccc
tyyt
View all comments
Show parent comment
1
u/Coder_d00d 1 3 Jun 11 '13
Onlines classes, books and various websites like stack overflow can all help you lead you to understand a programming language better or give you the tools to do programming.
I think the best way to get better is to solve challenges and write code. My first few challenges on this subreddit took me a long time and they were hard. But I did not back away. I kept at it. Each week I got better. I got stronger. It is like I went from running a mile in 20 minutes to running a mile in 10 minutes. And each week I keep coming back here and taking on the challenges, and I keep getting better. I will keep pushing for this. I have seen the positive results in my work since I started participating in /r/dailyprogrammer.