I think there is something wrong with the Golang test environment [Fixed]


  • 0
    D

    Simple solution based on binary search. However, I get an compile error says "Line 45: undefined: DriverSolution"

    func hIndex(citations []int) int {
    	n := len(citations)
    
    	low := 0
    	high := n - 1
    
    	for low <= high {
    		mid := low + (high-low)/2
    		if citations[mid] == n-mid {
    			return n - mid
    		} else if citations[mid] > n-mid {
    			high = mid - 1
    		} else {
    			low = mid + 1
    		}
    	}
    
    	return n - low
    }

Log in to reply
 

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