klausv
BAN USER
Questions (1)
Comments (2)
Reputation 15
- -1of 1 vote
AnswersImagine you have a computer keyboard that has all the letters mismatched
- klausv in United States
example:
typing q gives you a
typing w gives you b
all 26 letters in the alphabet are there, but typing one letter will give you another one
you are asked to write an algorithm to find whatever word you tried to type and count how many cycles you did to find the word
a restriction was set you need to type the whole word every time, not go character by character
note: a graph was suggested to represent the letter mappings| Report Duplicate | Flag | PURGE
Amazon SDE-2 Trees and Graphs
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
Hey, I don't know much info about the question. But yes you can choose whatever word you type each time. Your optimal strategy sounds good,
- klausv February 06, 2019In the second example using the word "ABC", sounds very much like the interviewer explained... that you could find "AB" in the same cycle and "C" in another shorter cycle.
But the main question is how to model this problem in code and get the running complexity. As I said the the interviewer used Graphs to model the cycles. Any idea is appreciated