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: // C++ program to find the length of the longest substring 
// without repeating characters 
#include <bits/stdc++.h> 
using namespace std; 
int longestUniqueSubsttr(string str) 
{ 
    int n = str.size(); 
  
    int res = 0; // result 
  
    // last index of all characters is initialized 
    // as -1 
    vector<int> lastIndex(256, -1); 
  
    // Initialize start of current window 
    int i = 0; 
  
    // Move end of current window 
    for (int j = 0; j < n; j++) { 
  
        // Find the last index of str[j] 
        // Update i (starting index of current window) 
        // as maximum of current value of i and last 
        // index plus 1 
        i = max(i, lastIndex[str[j]] + 1); 
  
        // Update result if we get a larger window 
        res = max(res, j - i + 1); 
  
        // Update last index of j. 
        lastIndex[str[j]] = j; 
    } 
    return res; 
} 

// Driver code 
int main() 
{   
	
	int t;
	cin>>t;
	while(t>0)
	{ t--;
		string s;
		cin>>s;
	int len = longestUniqueSubsttr(s); 
  cout<<len<<endl;


}
	
	return 0; 
} 
, In this Programming Language: C++, Now tell me if this Code is compilable or not?