public static void Main()
Console.WriteLine("Longest Substring Without Repeating Characters");
int res = LengthOfLongestSubstring("vikasnale");
Console.WriteLine("The length of the longest non-repeating character substring is " + res);
public static int LengthOfLongestSubstring(string s) {
for(int i=0; i< s.Length; i++){
for(int j=0; j< s.Length; j++){
res = Math.Max(res, j - i + 1);
public static bool isDistinct(string str, int i, int j){
bool[] visited = new bool[256];
for (int k = i; k <= j; k++) {
if (visited[str[k]] == true)