Twilio Onsite: Find the number of unique destinations

Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2019-05-14Added By Anonymous
Source: Link
Twilio Onsite: Find the number of unique destinations Given an array which contains 1-9 keys in a phone dial pad. To traverse this key pad you can only move either 1 step up/down/left/right first and then 3 steps agian in up/down/left/right direction or vice versa. Find out the number of unique destinations you can reach with a path of length 4 starting from a source key. Additionaly this dial pad has one disabled key (x), so you cannot take that path. Example: Input: [1,2,3,4,x,6,7,8,9] , Source: 3 Output: 7 Explanation: 1 2 3 4 x 6 7 8 9 Source: 3 path1 : 3->6->9->8 path2: 3->2->1->4 When there are no more paths left to explore from 3 so we explore the paths from 8 and 4 where we reached by traversing through 3 path3: 8->7->4->1 path4: 4->7->8->9 Again repeating the same steps we explore paths from 1 and 9 path5: 1->2->3->6 path6: 9->6->3->2 Then with 6 as next source path7: 6->9->8->7 Note: The paths we traverse may have the same nodes but the destinations must be unique.
Comments