Eat Study Love

먹고 공부하고 사랑하라

코딩문제 25

코딩테스트 문제 4개 Review

C - 2개 / C++ - 2개 이렇게 총 4개의 코딩문제를 3시간에 거쳐서 풀어보았다. 문제는 Time / Space Complexcity를 크게 고려하지 않고, 정답만 도출되면 인정되는 부분이라 어거지로 코드를 짜서 답을 도출해내는 데에는 성공을 했으나.. 앞으로 좀 더 효율적인 코딩을 하기 위해선 Coding Review정도는 하고 넘어가는 것이 좋을 거 같아 글을 적어본다. 문제의 출처도 제공되진 않지만, 시험이 끝나고 내가 스스로 복기 + 구글링/GPT를 이용해서 문제 출처를 추려내어 보았다.  1번 문제https://school.programmers.co.kr/learn/courses/30/lessons/42627 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을..

Coding_Practice 2024.12.02

Maximum Difference Between Node and Ancestor(Tree,Depth-First Search,Binary Tree)

https://leetcode.com/problems/maximum-difference-between-node-and-ancestor/description/Given the root of a binary tree, find the maximum value v for which there exist different nodes a and b where v = |a.val - b.val| and a is an ancestor of b.A node a is an ancestor of b if either: any child of a is equal to b or any child of a is an ancestor of b. Example 1:Input: root = [8,3,10,1,6,null,14,nul..

Coding_Practice 2024.11.28

Sort Characters By Frequency(Hash Table,String,Sorting,Heap (Priority Queue),Bucket Sort,Counting)

https://leetcode.com/problems/sort-characters-by-frequency/description/Given a string s, sort it in decreasing order based on the frequency of the characters. The frequency of a character is the number of times it appears in the string.Return the sorted string. If there are multiple answers, return any of them. Example 1:Input: s = "tree"Output: "eert"Explanation: 'e' appears twice while 'r' and..

Coding_Practice 2024.11.18

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

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

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

Find if Path Exists in Graph[Depth-First Search,Breadth-First Search,Union Find,Graph]

https://leetcode.com/problems/find-if-path-exists-in-graph/description/?envType=problem-list-v2&envId=graphThere is a bi-directional graph with n vertices, where each vertex is labeled from 0 to n - 1 (inclusive). The edges in the graph are represented as a 2D integer array edges, where each edges[i] = [ui, vi] denotes a bi-directional edge between vertex ui and vertex vi. Every vertex pair is c..

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