공부용/연습장20 [리트코드]2-2일차 열심히 공부해야 할 명목이 생겼다. https://leetcode.com/problems/maximum-depth-of-binary-tree/description/?envType=study-plan-v2&envId=top-interview-150 간단하게 풀었다. 2025. 3. 25. [리트코드]20일차 60문제 가량 풀었다. 86. Partition List/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode() {} * ListNode(int val) { this.val = val; } * ListNode(int val, ListNode next) { this.val = val; this.next = next; } * } */class Solution { public ListNode partition(ListNode head, int x) { ListNode slist = new ListNode(); .. 2025. 2. 28. 리트코드 19일차 19. Remove Nth Node From End of List/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode() {} * ListNode(int val) { this.val = val; } * ListNode(int val, ListNode next) { this.val = val; this.next = next; } * } */class Solution { public ListNode removeNthFromEnd(ListNode head, int n) { if (head.next == null && n 풀.. 2025. 2. 27. 리트코드 18일차 학교 졸업식이다!히히 학교가 꽃밭이 되었다. 예쁘다! 25. Reverse Nodes in k-Group/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode() {} * ListNode(int val) { this.val = val; } * ListNode(int val, ListNode next) { this.val = val; this.next = next; } * } */class Solution { public ListNode reverse(ListNode start, ListNode end){ ListNod.. 2025. 2. 25. [리트코드] 18일차 138. Copy List with Random Pointer/*// Definition for a Node.class Node { int val; Node next; Node random; public Node(int val) { this.val = val; this.next = null; this.random = null; }}*/class Solution { public Node copyRandomList(Node head) { Node dummy = new Node(0); Node answer= dummy; HashMap nodeMap = new HashMap(); while (.. 2025. 2. 24. [리트코드] 17일차 어제는 너무 재미난 걸 발견해버려서 그만 빼먹어버렸다.오늘은 일정이 있어서 하나밖에 못 풀었다... 21. Merge Two Sorted Listsclass Solution { public ListNode mergeTwoLists(ListNode list1, ListNode list2) { ListNode dummy = new ListNode(0); ListNode answer = dummy; while (list1 != null || list2!=null){ if (list1 != null && list2 != null){ if (list1.val 약속이 3월달에 갑자기 밀려와서 어떻게 처리해야 할.. 2025. 2. 23. [리트코드] 16일차 150. Evaluate Reverse Polish Notation class Solution { public int evalRPN(String[] tokens) { Stack st = new Stack(); for (int i = 0; i 예전에 풀어본 문제라 간단하게 해결했다. 224. Basic Calculatorclass Solution { public int calculate(String s) { Stack stack = new Stack(); int result = 0; int number = 0; int sign = 1; for (int i = 0; i해결하려다가.. 풀이가 안 보여서 그만 이걸.. 2025. 2. 21. 리트코드 16일차 452. Minimum Number of Arrows to Burst Balloonsclass Solution { public int findMinArrowShots(int[][] points) { Arrays.sort(points, (a,b) -> Integer.compare(a[0], b[0])); List section = new ArrayList(); int start = points[0][0]; int end = points[0][1]; for (int i = 1; i 간단하게 풀기는 풀었는데, 시간을 더 줄여보고 싶다.sort 자체에서 시간을 많이 잡아먹는다고 생각했는데 다른 풀이들을 보니 다들 비슷해서 일단 문.. 2025. 2. 20. [리트코드] 15일차 228. Summary Ranges오늘은 Inteval 이라는 주제의 문제들이다.class Solution { public List summaryRanges(int[] nums) { List answer = new ArrayList(); if (nums.length == 0) return answer; int prev = nums[0]; for (int i = 0; i "+nums[i]); } prev = nums[i+1]; } } if (nums[nums.length-1] == prev){ answer.add(Integer.toSt.. 2025. 2. 19. 이전 1 2 3 다음