public static int workTime(int[] nums, int N){
		if (nums.length <= 1){
			return nums.length;
		}
		
		int len = nums.length;
		int count = 0;
		Map<Integer, Integer> map = new HashMap<Integer, Integer>();
		
		for (int i = 0; i < nums.length; i++){
			if (map.size() == 0){
				map.put(nums[i], count);
				count++;
			} else if (!map.containsKey(nums[i])){
				map.put(nums[i], count);
				count++;
			} else if (map.containsKey(nums[i])){
				int pre = map.get(nums[i]);
				if (count - pre - 1 <= N){
					count += N - (count - pre - 1);
					map.put(nums[i], count);
					count++;
				} else {
					map.put(nums[i], count);
					count++;
				}
				
			}
		}
		return count;
	}