DSA Coding Contest - October '23 (Hacker Earth)
Guys today i solved the below problem in hacker earth DSA coding contest, it passed on sample test cases but i'm not able check it on hidden test cases because the time gets over so i don't know whether my logic is right or wrong and my code is not a efficient one. So if anyone know the logic help me to solve the problem more efficiently. Problem Statement : Given an array monsters denoting strengths of N monsters, we start with an empty battlefield, at each minute i, the i-th monster joins the battlefield and kills all monsters whose strength is less than or equal to his strength. Find the number of monsters alive in the battlefield at end of i-th minute for each 0†i <N. Input Format : T ==> no of test cases N ==> first line of each test cases contain the no of monsters M ===> second line of each test cases contain the N separated integers represents the strength of N monsters Output Format : For each test case, output N integers denoting the number of monsters alive after i-th minute for each 0 †i< N. Sample Input : 3 5 3 0 3 4 1 5 5 4 3 2 1 7 1 2 3 3 4 4 0 Sample Output : 1 2 1 1 2 1 2 3 4 5 1 1 1 1 1 1 2 My Solution : https://code.sololearn.com/cfM7pHbrrdGJ/?ref=app If you guys not understand the problem kindly use the below link to get more explanation about the problem https://www.hackerearth.com/challenges/competitive/dsa-coding-contest-october-23/algorithm/killer-monsters-0b5cb283/