SUBS - String it out
Given B[1-m], a string of characters from some alphabets, B^i is defined as string with the characters of B each repeating i times. For example, (abbacc)^3 = aaabbbbbbaaacccccc. Also, B^0 is the empty string.
Given strings X, Y made up of characters from 'a' - 'z' find the maximum value of M such that X^M is a subsequence of Y.
- The first line of the input contains a positive integer t <= 20, denoting the no. of test cases.
- The following 2t lines contain the value of X and Y for the cases.
- The description of the test cases follow one after the other.
- Line 2k contains the value of X for case k; (1 <= k <= t)
- Line 2k+1 contains the value of Y for case k; (1 <= k <= t).
- The no. of characters in X , Y will be <= 500010.
The output must contain t lines, each line corresponding to a test case. The value on the kth line should be the value of M for the kth pair of X and Y.
Though you get AC without binary search also, really appreciate beauty of problem.
Getting TLE even after applying binary search.
AC in first attempt.. :D good question
AC in 1st Go!!
AC in 1ST go :DLast edit: 2016-07-05 12:52:35
nope characters are not in lexicographic manner
are characters in lexicographic order?
Awesome application of binary search :)
Easy using binary search... ; )