Skip to content

Instantly share code, notes, and snippets.

@bparanj
Created April 6, 2018 20:38
Show Gist options
  • Save bparanj/f36b9ce1a0042f8588c972d65a33a21b to your computer and use it in GitHub Desktop.
Save bparanj/f36b9ce1a0042f8588c972d65a33a21b to your computer and use it in GitHub Desktop.
def remove_duplicates(string)
write_index = 0
for i in 0..string.length-1
found = false
for j in 0..write_index-1
if (string[i] == string[j])
found = true
break
end
end
unless found
string[write_index] = string[i]
write_index += 1
end
end
string[0, write_index]
end
p remove_duplicates('abbabcddbabcdeedebc')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment