Noob solution: Slow but works


  • 0
    C
    if n == 0:
            return 0
        if n == 1:
            return 1
    
        remain = n
        i = 1
        while i <= remain:
            remain -= i
            i += 1
            print "remain: " + str(remain)
        if remain < i:
            return i-1
        else:
            return i
    

Log in to reply
 

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