[Lv. 1] 달리기 경주
프로그래머스 2023. 4. 11. 00:26

문제 설명 얀에서는 매년 달리기 경주가 열립니다. 해설진들은 선수들이 자기 바로 앞의 선수를 추월할 때 추월한 선수의 이름을 부릅니다. 예를 들어 1등부터 3등까지 "mumu", "soe", "poe" 선수들이 순서대로 달리고 있을 때, 해설진이 "soe"선수를 불렀다면 2등인 "soe" 선수가 1등인 "mumu" 선수를 추월했다는 것입니다. 즉 "soe" 선수가 1등, "mumu" 선수가 2등으로 바뀝니다. 선수들의 이름이 1등부터 현재 등수 순서대로 담긴 문자열 배열 players와 해설진이 부른 이름을 담은 문자열 배열 callings가 매개변수로 주어질 때, 경주가 끝났을 때 선수들의 이름을 1등부터 등수 순서대로 배열에 담아 return 하는 solution 함수를 완성해주세요. 제한사항 5 ≤..

[Easy] 21. Merge Two Sorted Lists
leetCode 2022. 5. 18. 12:00

문제 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. Return the head of the merged linked list. 예시 Example 1: Input: list1 = [1,2,4], list2 = [1,3,4] Output: [1,1,2,3,4,4] Example 2: Input: list1 = [], list2 = [] Output: [] Example 3: Input: list1 = [], list2..

[Easy] 206. Reverse Linked List
leetCode 2022. 5. 18. 11:35

문제 Given the head of a singly linked list, reverse the list, and return the reversed list. 예시 Example 1: Input: head = [1,2,3,4,5] Output: [5,4,3,2,1] Example 2: Input: head = [1,2] Output: [2,1] Example 3: Input: head = [] Output: [] 제약조건 Constraints: The number of nodes in the list is the range [0, 5000]. -5000

[Medium] 994. Rotting Oranges
카테고리 없음 2022. 5. 17. 17:35

문제 You are given an m x n grid where each cell can have one of three values: 0 representing an empty cell, 1 representing a fresh orange, or 2 representing a rotten orange. Every minute, any fresh orange that is 4-directionally adjacent to a rotten orange becomes rotten. Return the minimum number of minutes that must elapse until no cell has a fresh orange. If this is impossible, return -1. 예시 x..

[Medium] 542. 01 Matrix
leetCode 2022. 5. 17. 14:56

문제 Given an m x n binary matrix mat, return the distance of the nearest 0 for each cell. The distance between two adjacent cells is 1. 예시 Example 1: Input: mat = [[0,0,0],[0,1,0],[0,0,0]] Output: [[0,0,0],[0,1,0],[0,0,0]] Example 2: Input: mat = [[0,0,0],[0,1,0],[1,1,1]] Output: [[0,0,0],[0,1,0],[1,2,1]] 제약 조건 Constraints: m == mat.length n == mat[i].length 1

[Medium] 116. Populating Next Right Pointers in Each Node
leetCode 2022. 5. 16. 16:17

https://leetcode.com/problems/populating-next-right-pointers-in-each-node/ Populating Next Right Pointers in Each Node - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제 You are given a perfect binary tree where all leaves are on the same level, and every parent has two children...

[Easy] 617. Merge Two Binary Trees
leetCode 2022. 5. 16. 15:57

https://leetcode.com/problems/merge-two-binary-trees/ Merge Two Binary Trees - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제 : You are given two binary trees root1 and root2. Imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped w..

Linked List Cycle
leetCode/Linked List 2022. 5. 3. 17:06

문제 : 주어진 연결 리스트에 사이클(cycle)이 있는지 검사하는 함수를 만들면 된다. 아래와 같은 연결 리스트가 cycle 이 있는 연결리스트이다. 순회하는데 다음 값이 null 이면 무조건 cycle 이 없는 것이다. 또한 자기 자신을 가리키는 것도 cycle에 포함된다. Example 1: Input: head = [3,2,0,-4], pos = 1 Output: true Explanation: There is a cycle in the linked list, where the tail connects to the 1st node (0-indexed). Example 2: Input: head = [1,2], pos = 0 Output: true Explanation: There is a cycl..