Page 1 of 1

Mail - Dubey, Suryansh (Contrac X HackerRank Question - Frequen x Chackerrank.com/test/eifsidn6q35/questions/94ck4sigaij

Posted: Thu May 05, 2022 12:48 pm
by answerhappygod
Mail Dubey Suryansh Contrac X Hackerrank Question Frequen X Chackerrank Com Test Eifsidn6q35 Questions 94ck4sigaij 1
Mail Dubey Suryansh Contrac X Hackerrank Question Frequen X Chackerrank Com Test Eifsidn6q35 Questions 94ck4sigaij 1 (69.01 KiB) Viewed 42 times
solve in java 8 in 30 minutes
solve in java 8
Mail - Dubey, Suryansh (Contrac X HackerRank Question - Frequen x Chackerrank.com/test/eifsidn6q35/questions/94ck4sigaij BETA Can't read the text? Switch theme 1. Frequency Sort Given an array of nitem values, sort the array in ascending order, first by the frequency of each value, then by the values themselves. Example n=6 items = [4, 5, 6, 5, 4, 3] • There are 2 values that occur once: [3, 6]. . • There are 2 values that occur twice: [4, 4, 5, 5]. • The array of items sorted by frequency and then by value in ascending order is [3, 6, 4, 4, 5,5] Function Description Complete the function itemsSort in the editor below. ← 1h 54m left ALL 1 2 3 5 X O: C# A Autocomplete Disabled wwww 0 0 ? ⠀ 25 26 27 public static List<int> items Sort (List<int> items) 28 { 29 var result = items.GroupBy (n=>n). Order By (g->g.Count()). ThenByg->g.Key). SelectMany (g=>g); 30 31 return result.ToList(); 32 33 Line: 29 Col: 77 Submit Test Results Custom Input Run Code Run Tests Compiled successfully. All available test cases passed Test case 0 Input (stdin) Run as Custom Input | Download Test case 1 1 5 2 3 3 1 ✔ Test case 2 4 2 5 2 Test case 3 Info O