Eat Study Love

먹고 공부하고 사랑하라

coding 32

Generate Parentheses[String,Dynamic Programming,Backtracking]

https://leetcode.com/problems/generate-parentheses/description/Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. Example 1:Input: n = 3Output: ["((()))","(()())","(())()","()(())","()()()"]Example 2:Input: n = 1Output: ["()"] Constraints:1 간단한 Dynamic Programming 코딩 한 번 해보기!문제는 쉬워 보이나, 막상 코딩하려니까 좀 짜친다.  1. Python아래까지 풀다가 GG. 뭔가 뒤에 방법이 생각 안 난다..

Coding_Practice 2024.11.14

Minimum One Bit Operations to Make Integers Zero[Dynamic Programming,Bit Manipulation,Memoization]

https://leetcode.com/problems/minimum-one-bit-operations-to-make-integers-zero/description/Given an integer n, you must transform it into 0 using the following operations any number of times:Change the rightmost (0th) bit in the binary representation of n.Change the ith bit in the binary representation of n if the (i-1)th bit is set to 1 and the (i-2)th through 0th bits are set to 0.Return the m..

Coding_Practice 2024.11.08

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

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

Palindrome Linked List[Linked List,Two Pointers,Stack,Recursion]

https://leetcode.com/problems/palindrome-linked-list/description/Given the head of a singly linked list, return true if it is a palindrome or false otherwise. Example 1:Input: head = [1,2,2,1]Output: trueExample 2:Input: head = [1,2]Output: false Constraints:The number of nodes in the list is in the range [1, 105].0  Follow up: Could you do it in O(n) time and O(1) space? 해당 문제를 Recursion / Data..

Coding_Practice 2024.09.23

Rotate List[Linked List,Two Pointers]

https://leetcode.com/problems/rotate-list/description/Given the head of a linked list, rotate the list to the right by k places. Example 1:Input: head = [1,2,3,4,5], k = 2Output: [4,5,1,2,3]Example 2:Input: head = [0,1,2], k = 4Output: [2,0,1] Constraints:The number of nodes in the list is in the range [0, 500].-100 0 1. C또 Naive하게 했다가 얻어 맞은 Time Limit ㅠㅠC는 빠른 언어라 상관 없을 줄 알았는데 얄짤 없네/** * Definit..

Coding_Practice 2024.08.20

Find K-th Smallest Pair Distance[H,Array,Two Pointers,Binary Search,Sorting]

https://leetcode.com/problems/find-k-th-smallest-pair-distance/description/?envType=daily-question&envId=2024-08-14The distance of a pair of integers a and b is defined as the absolute difference between a and b.Given an integer array nums and an integer k, return the kth smallest distance among all the pairs nums[i] and nums[j] where 0  Example 1:Input: nums = [1,3,1], k = 1Output: 0Explanation..

Coding_Practice 2024.08.14