You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
longestLength=Math.max(longestLength,j-i);// Not addding "+1" because I incremented j (j++) before inner while loop. If you increment j (j++) after inner while loop caclulate longestLength like this: `Math.max(longestLength, j - i + 1)`.
84
+
};
85
+
86
+
returnlongestLength;
87
+
};
88
+
89
+
57
90
/*
58
91
Time Complexity #
59
92
The time complexity of the above algorithm will be O(N)O(N) where ‘N’ is the number of characters in the input string. The outer for loop runs for all characters and the inner while loop processes each character only once, therefore the time complexity of the algorithm will be O(N+N)O(N+N) which is asymptotically equivalent to O(N)O(N).
0 commit comments