Interview Question
Junior Data Analyst Interview
-
ZalandoFind out whether an array/string contains non-repeated characters.
Tags:non-repeated character
AnswerAdd Tags
Interview Answers
2 Answers
▲
0
▼
Two solutions I gave 1. Make a bucket of ASCII (256),/ Eng Alphabet(26)characters.Look for count of A[i] . If 1 return false else return true in the end Loop if (!Memory[A[i]]) ) Increment (Count) else return false End return true 2. Create a Hashset/Hashtable. Look for A[i] . If found return false else return true in the end Loop if ! Get(A[i]) Push (A[i]) else return false End return true
Anonymous on
▲
0
▼
the complxity of your solution will be O(n) runtime and O(n) memory you can do better
Anonymous on
Add Answers or Comments
To comment on this, Sign In or Sign Up.