Longest Uncommon Subsequence II




@priyeshnngmail.com Basically this condition checks the most significant bit(MSB) of i after shifting j bits right i.e. (i>>j). It will return true only if MSB of i>>j is equal to 1.
If n AND 1==0 then MSB of n is 0 else MSB is 1.

@vinod23. Thanks for your explanation .I was more curios about how you are deciding to sum up the individual characters to make the substring combination based on this check

@priyeshnngmail.com Consider the string "abc" of length 3. Total number of subsequences will be 2^3=8. We iterate i from 0 to 2^31=7 and check the three MSB's of i and consider the characters whose corresponding bits is 1.
0  000  ""
1 001  "a"
2 010  "b"
3 011  "ab"
4 100  "c"
5 101 "ac"
6 110 "bc"
7 111 "abc"

@Jerry consider the case ["de","abc","abc"]. Here longest string is of length 3 but output is 2.