in this explaination you are using while loop inside a for loop
so the timr complexity should be o(n2)…but bhaiya explained that it is o(n)…i will appreciate if you will resolve my doubt
Time complexity related doubt
@gaurav_den while runs freq[i] times for every i(also i goes from 0 tolargest_element) , therefore actual time complexity is O(largest_element + number_of_elements) which is O(n)!, it would have been O(n^2) only and only if freq[i] = n for every i, which is impossible as sum of all freq[ ] is n.