[99클럽] 99클럽 코테 스터디 40일차 TIL - 그리디 (Greedy)
·
코딩테스트 연습/99클럽
오늘의 문제LeetCode - Optimal Partition of String (출처 하단 표기)비기너 문제를 금방 풀어서 미들러 문제도 풀어보았다. 문제Given a string s, partition the string into one or more substrings such that the characters in each substring are unique. That is, no letter appears in a single substring more than once.Return the minimum number of substrings in such a partition.Note that each character should belong to exactly one substring i..
[99클럽] 99클럽 코테 스터디 39일차 TIL - 힙 (Heap)
·
코딩테스트 연습/99클럽
오늘의 문제LeetCode - The K Weakest Rows in a Matrix (출처 하단 표기) 문제You are given an m x n binary matrix mat of 1's (representing soldiers) and 0's (representing civilians). The soldiers are positioned in front of the civilians. That is, all the 1's will appear to the left of all the 0's in each row.A row i is weaker than a row j if one of the following is true:The number of soldiers in row i is less t..
[99클럽] 99클럽 코테 스터디 38일차 TIL - 힙 (Heap)
·
코딩테스트 연습/99클럽
오늘의 문제LeetCode - Delete Greatest Value in Each Row (출처 하단 표기) 문제You are given an m x n matrix grid consisting of positive integers.Perform the following operation until grid becomes empty:Delete the element with the greatest value from each row. If multiple such elements exist, delete any of them.Add the maximum of deleted elements to the answer.Note that the number of columns decreases by one a..
[99클럽] 99클럽 코테 스터디 37일차 TIL - 스택 (Stack)
·
코딩테스트 연습/99클럽
오늘의 문제LeetCode - Minimum Add to Make Parentheses Valid (출처 하단 표기)비기너 문제가 얼마 걸리지 않아 미들러 문제도 같이 풀었다. 문제A parentheses string is valid if and only if:It is the empty string,It can be written as AB (A concatenated with B), where A and B are valid strings, orIt can be written as (A), where A is a valid string.You are given a parentheses string s. In one move, you can insert a parenthesis at any positi..
[99클럽] 99클럽 코테 스터디 36일차 TIL - 스택 (Stack)
·
코딩테스트 연습/99클럽
오늘의 문제백준 - 제로 (출처 하단 표기)비기너 문제를 완전 탐색으로 풀어서 스택에 관련된 문제를 하나 더 풀었다. 문제나코더 기장 재민이는 동아리 회식을 준비하기 위해서 장부를 관리하는 중이다.재현이는 재민이를 도와서 돈을 관리하는 중인데, 애석하게도 항상 정신없는 재현이는 돈을 실수로 잘못 부르는 사고를 치기 일쑤였다.재현이는 잘못된 수를 부를 때마다 0을 외쳐서, 가장 최근에 재민이가 쓴 수를 지우게 시킨다.재민이는 이렇게 모든 수를 받아 적은 후 그 수의 합을 알고 싶어 한다. 재민이를 도와주자! 입력첫 번째 줄에 정수 K가 주어진다. (1 ≤ K ≤ 100,000)이후 K개의 줄에 정수가 1개씩 주어진다. 정수는 0에서 1,000,000 사이의 값을 가지며, 정수가 "0"일 경우에는 가장 최근..
[99클럽] 99클럽 코테 스터디 35일차 TIL - 큐 (Queue)
·
코딩테스트 연습/99클럽
오늘의 문제LeetCode - Number of Recent Calls (출처 하단 표기) 문제You have a RecentCounter class which counts the number of recent requests within a certain time frame.Implement the RecentCounter class:RecentCounter() Initializes the counter with zero recent requests.int ping(int t) Adds a new request at time t, where t represents some time in milliseconds, and returns the number of requests that has happene..
[99클럽] 99클럽 코테 스터디 34일차 TIL - 큐 (Queue)
·
코딩테스트 연습/99클럽
오늘의 문제LeetCode -  Number of Students Unable to Eat Lunch, Find the Winner of the Circular Game (출처 하단 표기)비기너 문제를 풀고 나서 미들러 문제를 풀었는데 비슷한 문제를 푼 적이 있어 시간이 오래 걸리지 않았다. 비기너문제The school cafeteria offers circular and square sandwiches at lunch break, referred to by numbers 0 and 1 respectively. All students stand in a queue. Each student either prefers square or circular sandwiches.The number of sandwi..
[99클럽] 99클럽 코테 스터디 33일차 TIL - 정렬
·
코딩테스트 연습/99클럽
오늘의 문제LeetCode - Reordered Power of 2 (출처 하단 표기) 문제You are given an integer n. We reorder the digits in any order (including the original order) such that the leading digit is not zero.Return true if and only if we can do this so that the resulting number is a power of two. 제한사항1 입출력 예nreturn1true10false 풀이import java.util.*;class Solution { public boolean reorderedPowerOf2(int n) { //..
[99클럽] 99클럽 코테 스터디 32일차 TIL - 정렬
·
코딩테스트 연습/99클럽
오늘의 문제LeetCode - Neither Minimum nor Maximum (출처 하단 표기) 문제Given an integer array nums containing distinct positive integers, find and return any number from the array that is neither the minimum nor the maximum value in the array, or -1 if there is no such number.Return the selected integer. 제한사항1 1 All values in nums are distinct입출력 예numsreturn[3, 2, 1, 4]2 (or 3)[1, 2]-1[2, 1, 3]2 풀이첫번째 풀이clas..
[99클럽] 99클럽 코테 스터디 31일차 TIL - 문자열
·
코딩테스트 연습/99클럽
오늘의 문제LeetCode - Decode the Message (출처 하단 표기) 문제You are given the strings key and message, which represent a cipher key and a secret message, respectively. The steps to decode message are as follows:Use the first appearance of all 26 lowercase English letters in key as the order of the substitution table.Align the substitution table with the regular English alphabet.Each letter in message is th..