leetcode

    [LeetCode] Longest Consecutive Sequence (Java)

    ✉️문제 https://leetcode.com/problems/longest-consecutive-sequence/ Longest Consecutive Sequence - LeetCode Can you solve this real interview question? Longest Consecutive Sequence - Given an unsorted array of integers nums, return the length of the longest consecutive elements sequence. You must write an algorithm that runs in O(n) time. Example 1: Input: leetcode.com 🗝 문제풀이 class Solution { publi..

    [LeetCode] Course Schedule (Java)

    ✉️문제 https://leetcode.com/problems/course-schedule/description/ Course Schedule - LeetCode Can you solve this real interview question? Course Schedule - There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. You are given an array prerequisites where prerequisites[i] = [ai, bi] indicates that you must take co leetcode.com 📝 접근 위상 정렬 알고리즘을 이용한다. 🗝 문제풀이 class S..

    [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 📝 접근 방문한 노드에 방문했다는 표시를 한다. (이 문제에..