For this Question: Given a string S, you have to find the length of the longest substring of S such that all characters are unique in the substring i.e no character is repeating within that substring.

For example, for input string S = "abcama", the output is 3 as "abc" is the longest substring with distinct characters.The first line of input contains an integer T denoting the number of test cases.
The first and the only line of each test case contains the string S.

Constraints:
1 ≤ T ≤ 100
1 ≤ length of S ≤ 1000Print length of longest substring having such that all characters are unique .
Sample Input:
2
abababcdefababcdab
gccksfvrgccks

Sample Output:
6
7, I have written this Solution Code: 

def longestUniqueSubsttr(string):
 
    last_idx = {}
    max_len = 0
 
    start_idx = 0
 
    for i in range(0, len(string)):
       
        if string[i] in last_idx:
            start_idx = max(start_idx, last_idx[string[i]] + 1)
 
        max_len = max(max_len, i-start_idx + 1)
 
        last_idx[string[i]] = i
 
    return max_len


t=int(input())

while t > 0:
    s=input()
    print(longestUniqueSubsttr(s))
    t -= 1, In this Programming Language: Python, Now tell me if this Code is compilable or not?