Last active
February 4, 2020 16:04
-
-
Save abidkhan484/aa23a089b8dbba5a3d9ac59b6ced215a to your computer and use it in GitHub Desktop.
leetcode problem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python3 | |
| input_string = "abcabcbb" | |
| starting_idx = 0; max_length = 0; length = 0 | |
| i,j=0,0 | |
| for i in range(len(input_string)): | |
| for j in range(i-1, starting_idx-1, -1): | |
| if (input_string[j] == input_string[i]): | |
| starting_idx = j + 1 | |
| length = i - j | |
| break | |
| else: | |
| length += 1 | |
| max_length = max(max_length, length) | |
| print(max_length) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment