Machine Coding Round
Problem Solving Round
1) Find diameter of a binary tree and tell the time complexity. Optimise the solution.
http://www.geeksforgeeks.org/diameter-of-a-binary-tree/
2) Given a dictionary and two words start and target of same length. Find smallest path from start to target if exist, such that adjacent words in the chain only differ by one character and each word in the chain is a valid word (exists in dictionary).
http://www.geeksforgeeks.org/length-of-shortest-chain-to-reach-a-target-word/
Example
Problem Solving Round
1) Find diameter of a binary tree and tell the time complexity. Optimise the solution.
http://www.geeksforgeeks.org/diameter-of-a-binary-tree/
2) Given a dictionary and two words start and target of same length. Find smallest path from start to target if exist, such that adjacent words in the chain only differ by one character and each word in the chain is a valid word (exists in dictionary).
http://www.geeksforgeeks.org/length-of-shortest-chain-to-reach-a-target-word/
Example
Input: Dictionary = {POON, PLEE, SAME, POIE, PLEA, PLIE, POIN} start = TOON target = PLEA Output: 7 Explanation: TOON - POON - POIN - POIE - PLIE - PLEE - PLEA
No comments:
Post a Comment