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.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Hiring developers?
  1. Counting Sort 1
  2. Discussions

Counting Sort 1

Problem
Submissions
Leaderboard
Discussions
Editorial

Sort 452 Discussions, By:

recency

Please Login in order to post a comment

  • d_falcon_system1
    21 hours ago+ 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|
    Permalink
  • mallarupucharan1
    5 days ago+ 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|
    Permalink
  • imvic999
    6 days ago+ 0 comments

    test case 3 & 4 failed. Any idea to see the printed debug message?

    0|
    Permalink
  • mandarsakharkar
    1 week ago+ 1 comment

    case 5 is incorrect

    0|
    Permalink
  • pedroclericuzzi
    3 weeks ago+ 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
    }
    
    0|
    Permalink
Load more conversations

Need Help?


View editorial
View top submissions
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy