Issue in submitting the code

The following code is returning correct result 1 for manual test case [1], but returning wrong result 4 for the same automated test case [1]. Can anyone tell why it is returning two different results for the same input.

'''
class Solution {
static Map<Integer, Integer> map = new HashMap<>();

public int singleNumber(int[] nums) {
    int s = 0, e = nums.length-1;
    recurr(nums, s, e);
    for (Map.Entry<Integer, Integer> entry : map.entrySet())
        if (entry.getValue() == 1) return entry.getKey();
    return 0;
}

public void recurr(int[] nums, int s, int e) {
    if (s < e) {
        int mid = (s+e)/2;
        recurr(nums, s, mid);
        recurr(nums, mid+1, e);
    }
    else {
        if (!map.containsKey(nums[s])) map.put(nums[s], 1);
        else map.replace(nums[s], map.get(nums[s])+1);
    }
}

}
'''

image

Comments (1)