We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Counting Sort 1
- Discussions
Counting Sort 1
Counting Sort 1
+ 0 comments **var result = [] for (let i = 0; i < 100; i++) { result.push(0) } for (let i = 0; i < arr.length; i++) { result[arr[i]]++; } return result**
+ 0 comments def countingSort(arr): # Write your code here l=[0 for i in range(100)] for i in arr: l[i]+=1 return l
+ 0 comments test case 3 & 4 failed. Any idea to see the printed debug message?
+ 1 comment case 5 is incorrect
+ 1 comment JAVASCRIPT you guys think this is speed optimized??
function countingSort(arr) { const frequencyArray = [] for (let i = 0; i < arr.length; i++) { const current = arr[i] if (current > 99) continue; if (!frequencyArray[i] && i < 100) frequencyArray[i] = 0 if (!frequencyArray[current]) frequencyArray[current] = 0 frequencyArray[current]++; } return frequencyArray }
Load more conversations
Sort 452 Discussions, By:
Please Login in order to post a comment