Eat Study Love

먹고 공부하고 사랑하라

C 159

Find Minimum in Rotated Sorted Array2[Array,Binary Search]

https://leetcode.com/problems/find-minimum-in-rotated-sorted-array-ii/description/Suppose an array of length n sorted in ascending order is rotated between 1 and n times. For example, the array nums = [0,1,4,4,5,6,7] might become:[4,5,6,7,0,1,4] if it was rotated 4 times.[0,1,4,4,5,6,7] if it was rotated 7 times.Notice that rotating an array [a[0], a[1], a[2], ..., a[n-1]] 1 time results in the ..

Coding_Practice 2024.10.31

Kth Smallest Element in a BST[Tree,Depth-First Search,Binary Search Tree,Binary Tree]

https://leetcode.com/problems/kth-smallest-element-in-a-bst/description/Given the root of a binary search tree, and an integer k, return the kth smallest value (1-indexed) of all the values of the nodes in the tree. Example 1:Input: root = [3,1,4,null,2], k = 1Output: 1Example 2:Input: root = [5,3,6,2,4,null,null,1], k = 3Output: 3 Constraints:The number of nodes in the tree is n.1 0 Follow up: ..

Coding_Practice 2024.10.30

MaxProfit(Given a log of stock prices compute the maximum possible earning)

https://app.codility.com/programmers/lessons/9-maximum_slice_problem/max_profit/ MaxProfit coding task - Learn to Code - CodilityGiven a log of stock prices compute the maximum possible earning.app.codility.comAn array A consisting of N integers is given. It contains daily prices of a stock share for a period of N consecutive days. If a single share was bought on day P and sold on day Q, where 0..

Coding_Practice 2024.10.30

Maximum Depth of N-ary Tree[Tree,Depth-First Search,Breadth-First Search]

https://leetcode.com/problems/maximum-depth-of-n-ary-tree/description/?envType=problem-list-v2&envId=treeGiven a n-ary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.Nary-Tree input serialization is represented in their level order traversal, each group of children is separated by the null value (See ..

Coding_Practice 2024.10.29

Is Graph Bipartite?[Depth-First Search,Breadth-First Search,Union Find,Graph]

https://leetcode.com/problems/is-graph-bipartite/description/?envType=problem-list-v2&envId=graphThere is an undirected graph with n nodes, where each node is numbered between 0 and n - 1. You are given a 2D array graph, where graph[u] is an array of nodes that node u is adjacent to. More formally, for each v in graph[u], there is an undirected edge between node u and node v. The graph has the f..

Coding_Practice 2024.10.28

Deque 자료구조 만들어보기

https://leetcode.com/problems/design-circular-deque/사실 예전에 풀었던 문제인데, 다행히(?) 인간은 망각의 동물인지라 초면 인 것 마냥 풀었다. deque 구조의 delete / insert 등등의 method를 한번 구현해 보는 것이 골자! Design your implementation of the circular double-ended queue (deque).Implement the MyCircularDeque class:MyCircularDeque(int k) Initializes the deque with a maximum size of k.boolean insertFront() Adds an item at the front of Deque. Retu..

Coding_Practice 2024.10.27

My Calendar II[Array,Binary Search,Design,Segment Tree,Prefix Sum,Ordered Set]

https://leetcode.com/problems/my-calendar-ii/description/You are implementing a program to use as your calendar. We can add a new event if adding the event will not cause a triple booking.A triple booking happens when three events have some non-empty intersection (i.e., some moment is common to all the three events.).The event can be represented as a pair of integers start and end that represent..

Coding_Practice 2024.10.24