TrialPay interview question

Find the missing element in a string

Interview Answer

Anonymous

Jul 13, 2013

If elements are lower case alphabets, then we can solve it in O(n) using integer and bit manipulation. Assume that we only need to find first missing element in ascendant order. def find_missed(str) flag = 0 # n loops str.split('').each do |chr| flag = flag | (1 nil puts find_missed("abcdefghijklmnopqrtuvwxyz") #=> s However there is no information about elements, I'm not sure whether this approach is proper or not.