Eat Study Love

먹고 공부하고 사랑하라

코딩공부 88

Convert Sorted List to Binary Search Tree(Linked List,Divide and Conquer,Tree,Binary Search Tree,Binary Tree)

https://leetcode.com/problems/convert-sorted-list-to-binary-search-tree/description/Given the head of a singly linked list where elements are sorted in ascending order, convert it to a height-balanced binary search tree. Example 1:Input: head = [-10,-3,0,5,9]Output: [0,-3,9,-10,null,5]Explanation: One possible answer is [0,-3,9,-10,null,5], which represents the shown height balanced BST.Example ..

Coding_Practice 2025.02.17

SSSP(Single Source Shortest Path) / APSP(All-Pairs Shortest Path) 실습

Algorithm의 대명사인 Shortest Path와 관련된 실습이다.SSSP / APSP를 구현해보는 실습을 할 것이다. 대표적으로 FloydWarshall과 BellmanFord 알고리즘을 확인해보자. 실습자료는 위와 같다.#include #include #include #include // 아래 header는 내가 추가#include using namespace std;/*//////////////////////// Description ////////////////////////////There are n cities in a logistics network, numbered from 0 to n−1. The edges array represents the logistics routes bet..

Longest Palindrome Substring [Final 기출]

사실 Palindrome 문제는 유형도 많고, DP를 이용해서 풀면 편하지만 너~무 짜친다. 아오 하기 싫어! Longest Palindrome Substring(이하 LPS) 문제를 2개 풀게 됐는데, 하나는 10초컷 / 하나는 30분을 고민해도 어렵다.. 쉬운 문제는 아래와 같다.def is_palindromic(s: str) -> bool: """ > input 's' - A string consisting of only lowercase English letters (1 return a boolean """ # WRITE YOUR CODE HERE n = len(s) left = 0 right = n-1 while left  그냥 input에 대해..

Coding_Practice 2025.01.07

Python Binary Tree 문제[Final Test 기출]

문제의 요지와 Skleton code는 아래와 같다."""1. binary tree height 구하라2. binary tree balanced 맞는지 체크3. binary search tree 맞는지 체크4. 두 노드의 common ancestor 모두 구하기5. 두 노드의 lowest common ancestor 구하기"""  일단 문제에 쓰인 저 단어들이 각 무엇을 뜻하는지 부터 체크해보기1. height(T0)트리의 높이 구하기:정의: 트리의 높이는 루트 노드에서 가장 깊은 리프 노드까지의 경로 길이입니다.계산:루트 8의 왼쪽 서브트리의 높이 = 2루트 8의 오른쪽 서브트리의 높이 = 2따라서 전체 높이는 3.2. is_balanced(T0)트리가 균형 잡혔는지 여부:정의: 이진 트리가 균형 잡혔..

Coding_Practice 2024.12.17

Construct String With Repeat Limit(Hash Table,String,Greedy,Heap (Priority Queue)Counting)

https://leetcode.com/problems/construct-string-with-repeat-limit/description/?envType=daily-question&envId=2024-12-17You are given a string s and an integer repeatLimit. Construct a new string repeatLimitedString using the characters of s such that no letter appears more than repeatLimit times in a row. You do not have to use all characters from s.Return the lexicographically largest repeatLimit..

Coding_Practice 2024.12.17

Final Array State After K Multiplication Operations I(Array,Math,Heap (Priority Queue),Simulation)

https://leetcode.com/problems/final-array-state-after-k-multiplication-operations-i/description/?envType=daily-question&envId=2024-12-16You are given an integer array nums, an integer k, and an integer multiplier.You need to perform k operations on nums. In each operation:Find the minimum value x in nums. If there are multiple occurrences of the minimum value, select the one that appears first.R..

Coding_Practice 2024.12.16

코딩테스트 문제 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