[코테 풀이] Points That Intersect With Cars

시내·2024년 6월 29일

Q_2848) Points That Intersect With Cars

출처 : https://leetcode.com/problems/points-that-intersect-with-cars/

class Solution {
    public int numberOfPoints(List<List<Integer>> nums) {
        int count = 0;
        boolean[] visited = new boolean[101];
        for(List<Integer> l : nums){
            for(int j = l.get(0); j <= l.get(1); j++){
                visited[j]=true;
            }
        }
        for(boolean b : visited){
            if(b) count++;
        }
        return count;
    }
}
profile
contact 📨 ksw08215@gmail.com

0개의 댓글