How did people got 3ms run time?


  • 1
    S

    I saw that many people got 3ms runtime. I suspect that this may have occurred a long time back when test cases numbers may be. Does anyone recently got 3ms run time. If yes, can they share the codes here?

    This is the code that I used and got ~200 ms runtime:

    public class NumArray {
    
        int[] sumArray;
        public NumArray(int[] nums) {
            sumArray = new int[nums.length];
            if(nums.length != 0) {
                sumArray[0] = nums[0];
                for(int i = 1; i < nums.length; i++) {
                    sumArray[i] = nums[i] + sumArray[i - 1];
                }
            }
            
        }
        
        public int sumRange(int i, int j) {
            
            if(i == 0) {
                return sumArray[j];
            }
            return sumArray[j] - sumArray[i - 1];
        }
    }
    

  • 0
    X

    You are right. I rerun the my code which got 3 ms 8 months 1 week ago, and it got 254ms this time.


Log in to reply
 

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