I wrote the following solution to solve the problem during the contest, but I am getting TLE in 2 cases.
The algorithm which I designed is basically based on this article https://www.geeksforgeeks.org/queries-counts-multiples-array/ on GeekforGeeks but rather than updating the
freq_data at once I will first check how many multiples of the
arr[i] is present in the
freq_data and after finding all the multiples, I will keep track of maximum multiples for a number I found out till now.
Then when I traversed the whole array, I will print the value stored in the variable
max_star_val and that will be the answer.