[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..
[백준] 키로거
·
코딩테스트 연습/백준
문제창영이는 강산이의 비밀번호를 훔치기 위해서 강산이가 사용하는 컴퓨터에 키로거를 설치했다. 며칠을 기다린 끝에 창영이는 강산이가 비밀번호 창에 입력하는 글자를 얻어냈다.키로거는 사용자가 키보드를 누른 명령을 모두 기록한다. 따라서, 강산이가 비밀번호를 입력할 때, 화살표나 백스페이스를 입력해도 정확한 비밀번호를 알아낼 수 있다. 강산이가 비밀번호 창에서 입력한 키가 주어졌을 때, 강산이의 비밀번호를 알아내는 프로그램을 작성하시오. 강산이는 키보드로 입력한 키는 알파벳 대문자, 소문자, 숫자, 백스페이스, 화살표이다. 입력첫째 줄에 테스트 케이스의 개수가 주어진다. 각 테스트 케이스는 한줄로 이루어져 있고, 강산이가 입력한 순서대로 길이가 L인 문자열이 주어진다. (1 ≤ L ≤ 1,000,000) 강산..
[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..
[백준] 요세푸스 문제
·
코딩테스트 연습/백준
문제요세푸스 문제는 다음과 같다.1번부터 N번까지 N명의 사람이 원을 이루면서 앉아있고, 양의 정수 K(≤ N)가 주어진다. 이제 순서대로 K번째 사람을 제거한다. 한 사람이 제거되면 남은 사람들로 이루어진 원을 따라 이 과정을 계속해 나간다. 이 과정은 N명의 사람이 모두 제거될 때까지 계속된다. 원에서 사람들이 제거되는 순서를 (N, K)-요세푸스 순열이라고 한다. 예를 들어 (7, 3)-요세푸스 순열은 이다.N과 K가 주어지면 (N, K)-요세푸스 순열을 구하는 프로그램을 작성하시오. 입력첫째 줄에 N과 K가 빈 칸을 사이에 두고 순서대로 주어진다. (1 ≤ K ≤ N ≤ 5,000) 풀이import java.io.*;import java.util.*;public class Main { pub..