leetcode

    [LeetCode] Reverse Linked List (Java)

    ✉️문제 https://leetcode.com/problems/reverse-linked-list/description/ Reverse Linked List - LeetCode Can you solve this real interview question? Reverse Linked List - Given the head of a singly linked list, reverse the list, and return the reversed list. Example 1: [https://assets.leetcode.com/uploads/2021/02/19/rev1ex1.jpg] Input: head = [1,2,3,4,5] O leetcode.com 🗝 문제풀이 public class ReverseLinke..

    [LeetCode] Non-overlapping Intervals (Java)

    ✉️문제 https://leetcode.com/problems/non-overlapping-intervals/description/ Non-overlapping Intervals - LeetCode Can you solve this real interview question? Non-overlapping Intervals - Given an array of intervals intervals where intervals[i] = [starti, endi], return the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping. leetcode.com 🗝 문제풀이 겹치는 부분을 최소화..

    [알고리즘] 버킷 정렬

    [알고리즘] 버킷 정렬

    [Bucket Sort (버킷 정렬)] 버킷 정렬은 N개의 버킷으로 나눈 뒤, 각 버킷 안에 하나 이상의 값을 저장한다. 예를 들어보어 사과(2개), 배(2개), 망고(3개), 수박(1개) 총 8개의 과일이 있다고 가정해보자. 버킷 정렬에서는 다음과 같이 과일의 정보를 저장한다. 숫자 범위를 기준으로 버킷의 정렬 순서를 정할 수도 있다. 예를 들어 29, 25, 3, 49, 9, 37, 21, 43 이라는 숫자가 있으면 이를 10단위로 나누어 관리할 수 있다. [구현] 두 번째 예시를 기준으로 의사 코드를 작성하면 다음과 같다. function bucketSort(array, k) buckets ← N 크기의 빈 배열을 선언한다. M ← 가장 큰 숫자를 M으로 선언한다. for i = 1 to lengt..