11385 - Da Vinci Code
Solution Description : Ad hoc Simulation & Fibonacci Number Problem At first pregenerate first 46 Fibonacci number. 0->1, 1->1, 2->2, 3->3, 4->5, 5->8,......................... Now do the simulation what is say in question description. Example: 5 8 5 3 2 1 ABCDE Position Fibonacci Sequence: 5 4 3 2 1 A move to position 5 B move to position 4 c move to position 3 D move to position 2 E move to position 1 So the ans String is: EDCBA try this Input: 10 5 1 2 3 5 8 A 5 8 5 3 2 1 A 5 8 5 3 2 1 abcd 5 8 5 3 2 1 ABCDEFG 5 5 4 3 2 1 ABCDE 5 5 4 3 2 1 A a B b C c D d E e 1 13 ABCD 1 1836311903 aaaaaaaaaabbbbbbbbbbcccccccccc 1 4 ABC 1 2 a Output: A#### ####A ##### EDCBA DCBA DCBA #####A ############################## ## Note: Here # means space character ' ' |
||||||||||