From ebe960e085dae8c548cee5312b34cd20b37650d9 Mon Sep 17 00:00:00 2001 From: hyeonji0108 Date: Tue, 17 Nov 2026 22:46:11 +0900 Subject: [PATCH 1/2] Create 1348. Tweet Counts Per Frequency --- .../1348. Tweet Counts Per Frequency" | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 "leetcode3/\352\263\275\355\230\204\354\247\200/1348. Tweet Counts Per Frequency" diff --git "a/leetcode3/\352\263\275\355\230\204\354\247\200/1348. Tweet Counts Per Frequency" "b/leetcode3/\352\263\275\355\230\204\354\247\200/1348. Tweet Counts Per Frequency" new file mode 100644 index 00000000..3c1a8993 --- /dev/null +++ "b/leetcode3/\352\263\275\355\230\204\354\247\200/1348. Tweet Counts Per Frequency" @@ -0,0 +1,56 @@ +// 시간복잡도 : O(N+K) => 저장된 트윗 N개를 모두 순회하고 결과 리스트(O(K))로 변환 + +class TweetCounts { + private Map> tweetMap; + + public TweetCounts() { + tweetMap = new HashMap<>(); + } + + // 트윗 기록 + public void recordTweet(String tweetName, int time) { + tweetMap.putIfAbsent(tweetName, new TreeMap<>()); + TreeMap timeMap = tweetMap.get(tweetName); + timeMap.put(time, timeMap.getOrDefault(time, 0) + 1); + } + + // 트윗 수 집계 + public List getTweetCountsPerFrequency(String freq, String tweetName, int startTime, int endTime) { + List result = new ArrayList<>(); + // 해당 트윗이 없을 경우 값 반환 + if (!tweetMap.containsKey(tweetName)) { + return result; + } + + int interval = 0; + // 조회 단위 설정 + switch (freq) { + case "minute": + interval = 60; + break; + case "hour": + interval = 3600; + break; + case "day" : + interval = 86400; + break; + default: + throw new IllegalArgumentException("Invalid frequency"); + } + + TreeMap timeMap = tweetMap.get(tweetName); + int start = startTime; // 시작 시간 + while (start <= endTime) { + int end = Math.min(start + interval - 1, endTime); + int count = 0; + + for (Map.Entry entry : timeMap.subMap(start, true, end, true).entrySet()) { + count += entry.getValue(); + } + result.add(count); + start += interval; + } + + return result; + } +} From d852d76dd88b2c16828071ab0de250c05ae9d9e5 Mon Sep 17 00:00:00 2001 From: hyeonji0108 Date: Tue, 17 Nov 2026 22:46:56 +0900 Subject: [PATCH 2/2] Create 1536. Minimum Swaps to Arrange a Binary Grid --- ...6. Minimum Swaps to Arrange a Binary Grid" | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 "leetcode3/\352\263\275\355\230\204\354\247\200/1536. Minimum Swaps to Arrange a Binary Grid" diff --git "a/leetcode3/\352\263\275\355\230\204\354\247\200/1536. Minimum Swaps to Arrange a Binary Grid" "b/leetcode3/\352\263\275\355\230\204\354\247\200/1536. Minimum Swaps to Arrange a Binary Grid" new file mode 100644 index 00000000..3b5265e7 --- /dev/null +++ "b/leetcode3/\352\263\275\355\230\204\354\247\200/1536. Minimum Swaps to Arrange a Binary Grid" @@ -0,0 +1,19 @@ +class Solution { + public int minSwaps(int[][] grid) { + int n = grid.size(); + vector v(n); + for (int i = 0; i < n; i++) { + for (int j = n - 1; j >= 0; j--) { + if (grid[i][j] == 1) { + v[i] = j; + break; + } + } + } + + int cnt = 0; + for (int i = 0; i < n; i++) { + + } + } +}