From 6a0242b81cf37a88b72edbb86d196453da698b4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=97=BC=ED=98=9C=EC=A0=95?= <122238744+cyzlcyzl@users.noreply.github.com> Date: Tue, 25 Aug 2026 22:31:30 +0900 Subject: [PATCH 1/2] Create 3701. Compute Alternating Sum.java --- .../3701. Compute Alternating Sum.java" | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 "leetcode3/\354\227\274\355\230\234\354\240\225/3701. Compute Alternating Sum.java" diff --git "a/leetcode3/\354\227\274\355\230\234\354\240\225/3701. Compute Alternating Sum.java" "b/leetcode3/\354\227\274\355\230\234\354\240\225/3701. Compute Alternating Sum.java" new file mode 100644 index 00000000..54daa7e1 --- /dev/null +++ "b/leetcode3/\354\227\274\355\230\234\354\240\225/3701. Compute Alternating Sum.java" @@ -0,0 +1,13 @@ +// 짝수는 더하고 홀수는 빼기 +// o(n) + +class Solution { + public int alternatingSum(int[] nums) { + int sum = 0; + for (int i = 0; i Date: Tue, 25 Aug 2026 22:32:29 +0900 Subject: [PATCH 2/2] Create 785. Is Graph Bipartite?.java --- .../785. Is Graph Bipartite?.java" | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 "leetcode3/\354\227\274\355\230\234\354\240\225/785. Is Graph Bipartite?.java" diff --git "a/leetcode3/\354\227\274\355\230\234\354\240\225/785. Is Graph Bipartite?.java" "b/leetcode3/\354\227\274\355\230\234\354\240\225/785. Is Graph Bipartite?.java" new file mode 100644 index 00000000..e4a73f48 --- /dev/null +++ "b/leetcode3/\354\227\274\355\230\234\354\240\225/785. Is Graph Bipartite?.java" @@ -0,0 +1,27 @@ +// 인접한 노드는 다른 색 + +class Solution { + public boolean isBipartite(int[][] graph) { + int[] color = new int[graph.length]; + + for (int i = 0; i queue = new LinkedList<>(); + queue.offer(i); + color[i] = 1; + + while (!queue.isEmpty()) { + int node = queue.poll(); + for (int next : graph[node]) { + if (color[next] == color[node]) return false; + else if (color[next] == 0) { + color[next] = -color[node]; + queue.offer(next); + } + } + } + } + return true; + } +}