I am getting Time Limit Exceeded error with Golang


  • 1
    Z
    func countBits(num int) []int {
        bits := make([]int,num+1)
        for i:=1;i<num+1;i++ {
            bits[i] = bits[i&(i-1)]+1
        }   
        return bits
    }
    

    I am getting Time Limit Exceeded error
    Last executed input:123456

    But I don`t know why.Thanks for your help !!!!


  • 1
    P

    I think go is not well supported here...I use the same algorithm written with python and go, got Time Limit Exceeded for go while python code was accepted.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.