Company: flipkart grid_20thjuly
Difficulty: easy
Akash loves listening to music while jogging and wants to set up a new regime for his jogging with an app named Jog Track on his new iPod. He plans to complete his workout based on the playlist time. Initially, he sets an expected workout time D for the jog. Then he chooses N songs to be played while jogging. The songs in the playlist are denoted with S and T , where S is the song ID and T is the number of times he listens to that particular song. A song may get repeated in the playlist, as he is obsessed with some of the songs. He now needs to find his actual workout time Z for the day. The following algorithm calculates Z : Step 1 — Add up all T values of the playlist entries to get a sum X . Step 2 — Multiply X by the number of distinct song IDs in the playlist (that is, the count K obtained after removing duplicate song IDs) to get Y . Step 3 — Take the distinct songs and sort them in descending order of their corresponding time T . If a song ID occurs more than once in the playlis