HACKER RANK - ARRAYS - NEW YEAR CHAOS QUESTION: It is New Year's Day and people are in line for the Wonderland rollercoaster ride. Each person wears a sticker indicating their initial position in the queue from to . Any person can bribe the person directly in front of them to swap positions, but they still wear their original sticker. One person can bribe at most two others . Determine the minimum number of bribes that took place to get to a given queue order. Print the number of bribes, or, if anyone has bribed more than two people, print Too chaotic . Example If person bribes person , the queue will look like this: . Only bribe is required. Print 1 . Person had to bribe people to get to the current position. Print Too chaotic . SAMPLE INPUT: 2 5 2 1 5 3 4 5 2 5 1 3 4 OUTPUT: 3 Too chaotic SOLUTION: def minimumBribes(q): #...
Techy Pink provides knowledge for beginners in programming and technical subjects . It covers recent updates on software industry. Placement guidance is also provided. Stay tuned for becoming tech pro. Follow us on Instagram, Facebook and Youtube.