Why I get compile error ?


  • 2
    A

    Line 8: error: cannot access JsonArray

    public class Solution {
    public int majorityElement(int[] nums) {
        int len = nums.length;
    	int halfLen = (int) Math.ceil(len / 2.0F);
    	java.util.Map<Integer, Integer> map = new java.util.HashMap<>();
    	
    	for (int i = 0; i < len; ++i) {
    		if (map.containsKey(nums[i])) {
    			int count = map.get(nums[i]);
    			if (count + 1 >= halfLen) {
    				return nums[i];
    			}
    			map.put(nums[i], count + 1);
    		} else {
    			map.put(nums[i], 1);
    		}
    	}
    	
    	return -1;
    }
    

    }


  • 1
    P

    I got the same error.
    Maybe the system is crashed...


  • 0
    H

    I also go the same error, no idea why it runs well every where else.


  • 0

    Please try submitting again. Sorry for the compile error, it had been fixed.


  • 0
    A

    thank you, i will try again


  • 0
    C

    @1337c0d3r I'm afraid that it is not fixed in my case.
    I have been suffered from the case quite a lot, please fix it!


Log in to reply
 

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