Line 10: error: cannot find symbol: class Entry


  • 0
    A
    public class Solution {
        public boolean containsNearbyAlmostDuplicate(int[] nums, int k, int t) {
    	        Map<Integer, Integer> map = new HashMap<Integer, Integer>();
    	        for(int i =0;i<nums.length;i++){
    	            Integer oldv = map.put(nums[i], i);
    	            if(null!=oldv){
    	                map.remove(nums[i]);
    	            }
    	        }
    	        Iterator<Entry<Integer, Integer>> it = map.entrySet().iterator();
    	        if(!it.hasNext()){
    	            return false;
    	        }
    	        Map.Entry<Integer, Integer> entry = it.next();
    	        int curKey = entry.getKey();
    	        int curValue = entry.getValue();
    	        while(it.hasNext()){
    	            entry = it.next();
    	            int nextKey = entry.getKey();
    	            int nextValue = entry.getValue();
    	            if((nextKey-curKey<=t)&&(nextValue-curValue<=k)){
    	                return true;
    	            }
    	            curKey = nextKey;
    	            curValue = nextValue;
    	        }
    	        return false;
    	    }
    }
    

    Line 10: error: cannot find symbol: class Entry

    What's wrong with my code? It could complier through in my eclipse;


Log in to reply
 

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