알고리즘/LeetCode

    [LeetCode] Clone Graph (Java)

    ✉️문제 https://leetcode.com/problems/clone-graph/description/ Clone Graph - LeetCode Can you solve this real interview question? Clone Graph - Given a reference of a node in a connected [https://en.wikipedia.org/wiki/Connectivity_(graph_theory)#Connected_graph] undirected graph. Return a deep copy [https://en.wikipedia.org/wiki/Object_copy leetcode.com 🗝 문제풀이 class Solution { Node[] visited; publi..

    [LeetCode] Insert Interval

    ✉️문제 https://leetcode.com/problems/insert-interval/description/ Insert Interval - LeetCode Can you solve this real interview question? Insert Interval - You are given an array of non-overlapping intervals intervals where intervals[i] = [starti, endi] represent the start and the end of the ith interval and intervals is sorted in ascending order b leetcode.com 🗝 문제풀이 겹치는 부분의 조건을 확인하고 겹칠 때 마다 newIn..

    [LeetCode] Reorder List (Java)

    ✉️문제 https://leetcode.com/problems/reorder-list/description/ Reorder List - LeetCode Can you solve this real interview question? Reorder List - You are given the head of a singly linked-list. The list can be represented as: L0 → L1 → … → Ln - 1 → Ln Reorder the list to be on the following form: L0 → Ln → L1 → Ln - 1 → L2 leetcode.com 📝 접근 이 문제는 합병 정렬에 대한 기본적인 원리를 담고 있다. 먼저 어떻게 순서를 나열하는지 예제를 통해 알..

    [LeetCode] Merge Two Sorted Lists (Java)

    ✉️문제 https://leetcode.com/problems/merge-two-sorted-lists/description Merge Two Sorted Lists - LeetCode Can you solve this real interview question? Merge Two Sorted Lists - You are given the heads of two sorted linked lists list1 and list2. Merge the two lists in a one sorted list. The list should be made by splicing together the nodes of the first two lists leetcode.com 🗝 문제풀이 public ListNode m..

    [LeetCode] Linked List Cycle (Java)

    ✉️문제 https://leetcode.com/problems/linked-list-cycle/description/ Linked List Cycle - LeetCode Can you solve this real interview question? Linked List Cycle - Given head, the head of a linked list, determine if the linked list has a cycle in it. There is a cycle in a linked list if there is some node in the list that can be reached again by continuo leetcode.com 📝 접근 방문한 노드에 방문했다는 표시를 한다. (이 문제에..