Results: Congratulations Participants! You did a great job in the contest. Kudos to our top 5 programmers of SEPT18:
Who Will Break the Handi? For the given values of A, B & C, we run the loop until C reaches 1. Increment goal count for A if (A%C==0) i.e. C is a factor of A. Decrement A for every goal scored by A. Similarly, increment goal count for B if (B%C==0). Decrement B for every goal scored by B. Compare the goals scored by A & B and print who won.
Shweta and her Rakhi Given N distinct integers. Sort them and store them in a new array, say sorted_array. For a given value K, find what is the value at the Kth position in the original array. Output the index of this value from sorted_array.
Vishal's Journey The simplest method is to check all the given conditions. An efficient approach is to check the length of the string first, followed by the condition for the first character (Password should not begin with a number). The remaining conditions can be checked in any way it fits you.
Nishant's Diwali Puzzle The first hurdle is accepting the input as the number of elements N is not provided. The easiest way to overcome is to read till the end of the line, i.e until you encounter '\n'. Next, search for the even sub-sequence. From every such sub-sequence, get the maximum value. Store them in an array. Finally, print the minimum value from this array. If no even terms are present in the sequence, simply print '-1'.
Aarya Celebrates Dussehra This problem can be solved using DFS and Sorting the distances calculated from the Source Node. We run DFS from the source node and maintain a list distance for each node. The distance for each node increases via DFS. Remember, once a node is visited we cannot revisit the node. After the traversal, we have to sort the list of node and distances alphabetically which means e.g.: (A,3), (C,2), (B,1), (F, 1), (D, 3), (E, 2) Then sorted result would be (B,1), (F, 1), (C,2), (E, 2), (A,3), (D,3) So answer for this example will be B and D.
Solutions: Click Here (Note: The solutions are accesible only using GST email addresses)
Thank you, everyone, for participating! Stay tuned for more contests.