Skip to content

Instantly share code, notes, and snippets.

@fida10
Created August 8, 2022 03:54
Show Gist options
  • Save fida10/3f8ef09d6b0557df624515e434dacbc6 to your computer and use it in GitHub Desktop.
Save fida10/3f8ef09d6b0557df624515e434dacbc6 to your computer and use it in GitHub Desktop.
s = "abccbaacz";
lowestIndexOfSecond = len(s);
for i in range(0, len(s)):
currentVal = s[i];
currentIndexOfSecond = len(s);
for j in range(i + 1, len(s)):
if (s[j] == currentVal):
currentIndexOfSecond = j;
break;
if (currentIndexOfSecond < lowestIndexOfSecond):
lowestIndexOfSecond = currentIndexOfSecond;
print(s[lowestIndexOfSecond]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment