알고리즘/LeetCode

    [LeetCode] Remove Nth Node From End of List (Java)

    ✉️문제 https://leetcode.com/problems/remove-nth-node-from-end-of-list/description/ Remove Nth Node From End of List - LeetCode Can you solve this real interview question? Remove Nth Node From End of List - Given the head of a linked list, remove the nth node from the end of the list and return its head. Example 1: [https://assets.leetcode.com/uploads/2020/10/03/remove_ex1.jpg] leetcode.com 📝 접근 O(..

    [LeetCode] Merge k Sorted Lists (Java)

    ✉️문제 https://leetcode.com/problems/merge-k-sorted-lists/description/ Merge k Sorted Lists - LeetCode Can you solve this real interview question? Merge k Sorted Lists - You are given an array of k linked-lists lists, each linked-list is sorted in ascending order. Merge all the linked-lists into one sorted linked-list and return it. Example 1: Input: lis leetcode.com 🗝 문제풀이 1. Collection과 Collecti..

    [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] Longest Consecutive Sequence (Java)

    ✉️문제 https://leetcode.com/problems/longest-consecutive-sequence/description/ 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 Solu..

    [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..