Loading...
「ツール」は右上に移動しました。
利用したサーバー: natural-voltaic-titanium
4いいね 112回再生

Sort Array by Increasing Frequency | Leetcode 1636 in Java | Must do sorting Questions | TOP DSA

In this question its Given an array of integers nums, sort the array in increasing order based on the frequency of the values. If multiple values have the same frequency, sort them in decreasing order.

Return the sorted array.

My Approach is simple, i am first storing the frequency of all the elements in an HashMap, and then i am creating one Priority Queue that stores Integer array of size 2 where first element is array element and 2nd element is the frequency of the first element. to store them in ProrityQueue i have modified comparator in such a way that if same frequency then i am taking the bigger value of the first integer otherwise smallest frequency integer would populated first in the answer array repeated their frequency times in the array.

DSA Algorithms :-
   • Topological sorting in Hindi | Topological...  
Design HLD:-
   • Design E-commerce website | Design Amazon ...  

#coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #india #hindiexplanation #hindiexplained #easyexplaination #interview #interviewtips
#interviewpreparation #interview_ds_algo #hinglish

コメント