Viasat Interview Question

How would you find the first non repeating character in a string?

Interview Answers

Anonymous

May 6, 2012

My answer was to go through the string adding the characters to a hash and updating the value. Then going through the string again and checking the characters. The first key that has value 1 is the first non repeating character

2

Anonymous

Mar 9, 2017

x = "raviteja" y = {} for i in x: if i in y: print i, "repeated" break else: y[i]=1

1