Eat Study Love

먹고 공부하고 사랑하라

코린이 36

Function Overloading and Templates

금번 C++ 공부에선, Function Overloading 과 Templates 부분을 공부하고 관련 내용을 실습해보겠다.실습자료는 아래와 같다.  기본적으로 Function의 parameter에는 defulat 값을 넣을 수 있다.int divide( int a, int b = 2 ) { return a/b;} Function의 Overloading이란, Function들끼리 같은 이름을 Share하는데 Parameter type에 따라서 Return이 달라지는 것이다. 이 때, Return type만 가지고는 Function들 끼리 overload 할 수 없다. 다음은, Function Overload의 예시다. 보면, mySwap이라는 함수가 있는데, 이름이 다 같아도 input data의 typ..

Maximum Employees to Be Invited to a Meeting(Depth-First Search,Graph,Topological Sort)

https://leetcode.com/problems/maximum-employees-to-be-invited-to-a-meeting/description/?envType=daily-question&envId=2025-01-26A company is organizing a meeting and has a list of n employees, waiting to be invited. They have arranged for a large circular table, capable of seating any number of employees.The employees are numbered from 0 to n - 1. Each employee has a favorite person and they will..

Coding_Practice 2025.01.26

Make Lexicographically Smallest Array by Swapping Elements(Array,Union Find,Sorting)

https://leetcode.com/problems/make-lexicographically-smallest-array-by-swapping-elements/description/?envType=daily-question&envId=2025-01-25You are given a 0-indexed array of positive integers nums and a positive integer limit.In one operation, you can choose any two indices i and j and swap nums[i] and nums[j] if |nums[i] - nums[j]| Return the lexicographically smallest array that can be obtai..

Coding_Practice 2025.01.25

First Completely Painted Row or Column(Array,Hash Table,Matrix)

https://leetcode.com/problems/first-completely-painted-row-or-column/description/?envType=daily-question&envId=2025-01-20You are given a 0-indexed integer array arr, and an m x n integer matrix mat. arr and mat both contain all the integers in the range [1, m * n].Go through each index i in arr starting from index 0 and paint the cell in mat containing the integer arr[i].Return the smallest inde..

Coding_Practice 2025.01.20

Minimum Length of String After Operations(Hash Table,String,Counting)

https://leetcode.com/problems/minimum-length-of-string-after-operations/description/?envType=daily-question&envId=2025-01-13You are given a string s.You can perform the following process on s any number of times:Choose an index i in the string such that there is at least one character to the left of index i that is equal to s[i], and at least one character to the right that is also equal to s[i]..

Coding_Practice 2025.01.13

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

Unique Binary Search Trees(Math,Dynamic Programming,Tree,Binary Search Tree,Binary Tree)

https://leetcode.com/problems/unique-binary-search-trees/description/Given an integer n, return the number of structurally unique BST's (binary search trees) which has exactly n nodes of unique values from 1 to n. Example 1:Input: n = 3Output: 5Example 2:Input: n = 1Output: 1 Constraints:1 그래도 가볍게나마 BST문제도 풀어봐야지..! Linked List , Tree 이런 걸 자꾸만 건들자 근데 이건,, Tree 문제라기보단 수학 문제 같다.. 흐음..  1. Python 일단..

Coding_Practice 2025.01.06

Minimum Number of Operations to Move All Balls to Each Box(Array,String,Prefix Sum)

https://leetcode.com/problems/minimum-number-of-operations-to-move-all-balls-to-each-box/description/?envType=daily-question&envId=2025-01-06You have n boxes. You are given a binary string boxes of length n, where boxes[i] is '0' if the ith box is empty, and '1' if it contains one ball.In one operation, you can move one ball from a box to an adjacent box. Box i is adjacent to box j if abs(i - j)..

Coding_Practice 2025.01.06