Solved HackerRank
This is a page to solve the problem in page HackerRank in many languages.
Marc's Cakewalk
Marc loves cupcakes, but he also likes to stay fit. He eats cupcakes in one sitting, and each cupcake has a calorie count, . After eating a cupcake with calories, he must walk at least 2^j * c (where is the number cupcakes he has already eaten) miles to maintain his weight.
Given the individual calorie counts for each of the cupcakes, find and print a long integer denoting the minimum number of miles Marc must walk to maintain his weight. Note that he can eat the cupcakes in any order.
Sparse Arrays
There are N strings. Each string's length is no more than 20 characters. There are also Q queries. For each query, you are given a string, and you need to find out how many times this string occurred previously.
Left Rotation
A left rotation operation on an array of size n shifts each of the array's elements 1 unit to the left. For example, if 2 left rotations are performed on array [1,2,3,4,5], then the array would become [3,4,5,1,2].
Given an array of n integers and a number, d, perform d left rotations on the array. Then print the updated array as a single line of space-separated integers.