InterviewBit Academy is now Scaler!
Learn Tech Skills from Scratch @ Scaler EDGE

Repeating Sub-Sequence


Problem Description

Given a string A, find length of the longest repeating sub-sequence such that the two subsequence don’t have same string character at same position,

i.e., any i’th character in the two subsequences shouldn’t have the same index in the original string.

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



Problem Constraints

1 <= |A| <= 100



Input Format

The first and the only argument of input contains a string A.



Output Format

Return an integer, 0 or 1:

    => 0 : False
    => 1 : True


Example Input

Input 1:

 A = "abab"

Input 2:

 A = "abba"


Example Output

Output 1:

 1

Output 2:

 0


Example Explanation

Explanation 1:

 "ab" is repeated.

Explanation 2:

 There is no repeating subsequence.


NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving Repeating Sub-Sequence on Interview Code Editor
Hints
  • Hint 1
  • Solution Approach
  • Complete Solution
Asked In:

Discussion


Loading...
Click here to start solving coding interview questions