Java443 [LeetCode/Java] 94. Binary Tree Inorder Traversal -Code/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode() {} * TreeNode(int val) { this.val = val; } * TreeNode(int val, TreeNode left, TreeNode right) { * this.val = val; * this.left = left; * this.right = right; * } * } */class Solution { List answer; public List i.. 2025. 11. 23. [백준/Java] 15216번 Another Brick in the Wall -Codeimport java.util.Scanner;public class BOJ15216 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int h = sc.nextInt(); int w = sc.nextInt(); int n = sc.nextInt(); int[] blocks = new int[n]; for (int i = 0; i 2025. 11. 23. [LeetCode/Java] 83. Remove Duplicates from Sorted List -Codeclass Solution { public ListNode deleteDuplicates(ListNode head) { // 처음 위치 저장 ListNode answer = new ListNode(-101); // 현재 노드 위치 저장 ListNode cur = answer; while(head != null) { int now = head.val; // 현재 값과 다른 경우 저장 if (now != cur.val) { ListNode addNode = new ListNode(now); cur.next = addNod.. 2025. 11. 22. [LeetCode/Java] 70. Climbing Stairs -Codeclass Solution { public int climbStairs(int n) { int before = 0; int answer = 1; for (int i = 0; i 2025. 11. 22. [LeetCode/Java] 69. Sqrt(x) -Codeclass Solution { public int mySqrt(int x) { return (int) Math.sqrt(x); }} 2025. 11. 22. [LeetCode/Java] 67. Add Binary -Codeclass Solution { public String addBinary(String a, String b) { int aIndex = a.length() - 1; int bIndex = b.length() - 1; int now = 0; StringBuilder answer = new StringBuilder(); // 마지막 수부터 더하기 while (now > 0 || aIndex >= 0 || bIndex >= 0) { if (aIndex >= 0) { now += a.charAt(aIndex--) - '0'; } if (bIndex .. 2025. 11. 22. 이전 1 ··· 53 54 55 56 57 58 59 ··· 74 다음