Answers for "convert java to javascript"

0

convert java to javascript

class Solution {
    public int[] findingUsersActiveMinutes(int[][] logs, int k) {
        int[] ans = new int[k];
        Set<Integer> set = new HashSet<>();
        Arrays.sort(logs, (a, b) -> a[0] - b[0]);
        int x = logs[0][0];
        for(int i=0; i<logs.length; i++) {
        	if(logs[i][0] != x) {
        		ans[set.size()-1]++;
        		set.clear();
        	}
        	x = logs[i][0];
        	set.add(logs[i][1]);
        	if(i==logs.length-1) {
        		ans[set.size()-1]++;
        	}
        }
        return ans;
    }
}
Posted by: Guest on October-21-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language