rd22
BAN USER- 2of 4 votes
AnswersA frequent traveller collects all his travel tickets.
- rd22 in India
A ticket has only 2 attributes, Start Journey Location name and Destination Name. Example from Delhi to Mumbai.
At the end of the year, the traveller gets all his tickets together and tries to map his journey across the year. Print his travel route in a readable format. He does not remember his start location.
Edit: he can visit a location multiple times, and can also go back and forth a place several times.| Report Duplicate | Flag | PURGE
Amazon Algorithm - 0of 0 votes
AnswersYou are given a dictionary of fixed words, you need to find the maximum chain of words that can be formed by any of these words. A chain is formed by picking a word and removing one character from it and this newly formed word should be present in the dictionary.
- rd22 in India
As an example say the dictionary consists of {a, b, ba, bca, bda, bdca}, then the word that forms the biggest chain will be bdca -> bca -> ba -> (a or b), i.e. a chain of length 4.| Report Duplicate | Flag | PURGE
Amazon Algorithm
The idea is to recursively solve the problem
1. Start with a count of zero, start position
2. if the next character is "L", reduce the count by 1
3. If the char is "R", increase the count by 1
4. If the char is "?" consider both the cases, left and right and pick the max.
- rd22 March 05, 2017