Repeating Sub-Sequence

Given a string, find if there is any sub-sequence that repeats itself.
A sub-sequence of a string is defined as a sequence of characters generated by deleting some characters in the string without changing the order of the remaining characters.

Input:
string

Output:

0/1
0 -> No
1 -> Yes 

Example:

abab ------> yes, ab is repeated. So, return 1. 
abba ------> No, a and b follow different order. So, return 0. 

NOTE : sub-sequence length should be greater than or equal to 2

Interview Code Editor
Hints
  • Hint 1
  • Solution Approach
  • Complete Solution
1869 successful submissions.
Asked In:
  • Google
Click here to jump start your coding interview preparation