[Easy] 896. Monotonic Array
leetCode 2022. 6. 9. 11:22

문제 An array is monotonic if it is either monotone increasing or monotone decreasing. An array nums is monotone increasing if for all i

[Easy] 28. Implement strStr()
leetCode 2022. 6. 9. 11:16

문제 Implement strStr(). Given two strings needle and haystack, return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. Clarification: What should we return when needle is an empty string? This is a great question to ask during an interview. For the purpose of this problem, we will return 0 when needle is an empty string. This is consistent to C's s..

[Easy] 303. Range Sum Query - Immutable
leetCode 2022. 6. 8. 13:27

문제 Given an integer array nums, handle multiple queries of the following type: Calculate the sum of the elements of nums between indices left and right inclusive where left

[Easy] 1603. Design Parking System
leetCode 2022. 6. 8. 13:25

문제 Design a parking system for a parking lot. The parking lot has three kinds of parking spaces: big, medium, and small, with a fixed number of slots for each size. Implement the ParkingSystem class: ParkingSystem(int big, int medium, int small) Initializes object of the ParkingSystem class. The number of slots for each parking space are given as part of the constructor. bool addCar(int carType)..

[Easy] 404. Sum of Left Leaves
leetCode 2022. 6. 6. 17:40

문제 Given the root of a binary tree, return the sum of all left leaves. A leaf is a node with no children. A left leaf is a leaf that is the left child of another node. root이진 트리가 주어지면 모든 왼쪽 잎의 합을 반환합니다. 리프는 자식이 없는 노드입니다 . 왼쪽 리프 는 다른 노드의 왼쪽 자식인 리프입니다. 예시 Example 1: Input: root = [3,9,20,null,null,15,7] Output: 24 Explanation: There are two left leaves in the binary tree, with values 9 and 15 resp..

[Easy] 104. Maximum Depth of Binary Tree
leetCode 2022. 6. 6. 16:59

문제 Given the root of a binary tree, return its maximum depth. A binary tree's maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. 이진 root트리의 최대 깊이를 반환합니다 . 이진 트리의 최대 깊이 는 루트 노드에서 가장 먼 잎 노드까지 가장 긴 경로를 따라 있는 노드의 수입니다. 예시 Example 1: Input: root = [3,9,20,null,null,15,7] Output: 3 Example 2: Input: root = [1,null,2] Output: 2 제약 조건 Constrain..

[Easy] 876. Middle of the Linked List
leetCode 2022. 6. 6. 14:35

문제 Given the head of a singly linked list, return the middle node of the linked list. If there are two middle nodes, return the second middle node. head단일 연결 목록이 주어지면 연결 목록 의 중간 노드를 반환합니다 . 두 개의 중간 노드가 있는 경우 두 번째 중간 노드를 반환 합니다. 예시 Example 1: Input: head = [1,2,3,4,5] Output: [3,4,5] Explanation: The middle node of the list is node 3. Example 2: Input: head = [1,2,3,4,5,6] Output: [4,5,6] Explana..

[Easy] 1290. Convert Binary Number in a Linked List to Integer
leetCode 2022. 6. 6. 14:25

문제 Given head which is a reference node to a singly-linked list. The value of each node in the linked list is either 0 or 1. The linked list holds the binary representation of a number. Return the decimal value of the number in the linked list. 단일 head연결 목록에 대한 참조 노드가 지정됩니다. 연결 목록의 각 노드 값은 0또는 1입니다. 연결 목록은 숫자의 이진 표현을 보유합니다. 연결 목록에 있는 숫자 의 10진수 값 을 반환합니다 . 예시 Example 1: Input: head = [1,0,1] Outp..