분류 전체보기 277

[string]99클럽 코테 스터디 4일차 TIL + 프로그래머스/1/81301. 숫자 문자열과 영단어

문제 설명네오와 프로도가 숫자놀이를 하고 있습니다. 네오가 프로도에게 숫자를 건넬 때 일부 자릿수를 영단어로 바꾼 카드를 건네주면 프로도는 원래 숫자를 찾는 게임입니다.다음은 숫자의 일부 자릿수를 영단어로 바꾸는 예시입니다.1478 → "one4seveneight"234567 → "23four5six7"10203 → "1zerotwozero3"이렇게 숫자의 일부 자릿수가 영단어로 바뀌어졌거나, 혹은 바뀌지 않고 그대로인 문자열 s가 매개변수로 주어집니다. s가 의미하는 원래 숫자를 return 하도록 solution 함수를 완성해주세요.참고로 각 숫자에 대응되는 영단어는 다음 표와 같습니다.숫자영단어0zero1one2two3three4four5five6six7seven8eight9nine제한사항1 ≤ s..

[string]99클럽 코테 스터디 3일차 TIL + 프로그래머스/1/147355. 크기가

문제 설명문자열 s가 입력되었을 때 다음 규칙을 따라서 이 문자열을 여러 문자열로 분해하려고 합니다.먼저 첫 글자를 읽습니다. 이 글자를 x라고 합시다.이제 이 문자열을 왼쪽에서 오른쪽으로 읽어나가면서, x와 x가 아닌 다른 글자들이 나온 횟수를 각각 셉니다. 처음으로 두 횟수가 같아지는 순간 멈추고, 지금까지 읽은 문자열을 분리합니다.s에서 분리한 문자열을 빼고 남은 부분에 대해서 이 과정을 반복합니다. 남은 부분이 없다면 종료합니다.만약 두 횟수가 다른 상태에서 더 이상 읽을 글자가 없다면, 역시 지금까지 읽은 문자열을 분리하고, 종료합니다.문자열 s가 매개변수로 주어질 때, 위 과정과 같이 문자열들로 분해하고, 분해한 문자열의 개수를 return 하는 함수 solution을 완성하세요.제한사항1 ≤..

[string]99클럽 코테 스터디 2일차 TIL + 프로그래머스/1/147355. 크기가 작은 부분문자열/

문제 설명숫자로 이루어진 문자열 t와 p가 주어질 때, t에서 p와 길이가 같은 부분문자열 중에서, 이 부분문자열이 나타내는 수가 p가 나타내는 수보다 작거나 같은 것이 나오는 횟수를 return하는 함수 solution을 완성하세요.예를 들어, t="3141592"이고 p="271" 인 경우, t의 길이가 3인 부분 문자열은 314, 141, 415, 159, 592입니다. 이 문자열이 나타내는 수 중 271보다 작거나 같은 수는 141, 159 2개 입니다.제한사항1 ≤ p의 길이 ≤ 18p의 길이 ≤ t의 길이 ≤ 10,000t와 p는 숫자로만 이루어진 문자열이며, 0으로 시작하지 않습니다.입출력 예tpresult"3141592""271"2"500220839878""7"8"10203""15"3입출력..

[string]99클럽 코테 스터디 1일차 TIL + 프로그래머스/1/12916. 문자열 내 p와 y의 개수

문제 설명대문자와 소문자가 섞여있는 문자열 s가 주어집니다. s에 'p'의 개수와 'y'의 개수를 비교해 같으면 True, 다르면 False를 return 하는 solution를 완성하세요. 'p', 'y' 모두 하나도 없는 경우는 항상 True를 리턴합니다. 단, 개수를 비교할 때 대문자와 소문자는 구별하지 않습니다.예를 들어 s가 "pPoooyY"면 true를 return하고 "Pyy"라면 false를 return합니다.제한사항문자열 s의 길이 : 50 이하의 자연수문자열 s는 알파벳으로만 이루어져 있습니다.입출력 예sanswer"pPoooyY"true"Pyy"false입출력 예 설명입출력 예 #1'p'의 개수 2개, 'y'의 개수 2개로 같으므로 true를 return 합니다.입출력 예 #2'p'의..

[DP]99클럽 코테 스터디 40일차 TIL + 0121-best-time-to-buy-and-sell-stock

121. Best Time to Buy and Sell StockEasyYou are given an array prices where prices[i] is the price of a given stock on the ith day.You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock.Return the maximum profit you can achieve from this transaction. If you cannot achieve any profit, return 0. Example 1:Input: pric..

[DP]99클럽 코테 스터디 39일차 TIL + 1236-n-th-tribonacci-number

1236. N-th Tribonacci NumberEasyThe Tribonacci sequence Tn is defined as follows: T0 = 0, T1 = 1, T2 = 1, and Tn+3 = Tn + Tn+1 + Tn+2 for n >= 0.Given n, return the value of Tn. Example 1:Input: n = 4Output: 4Explanation:T_3 = 0 + 1 + 1 = 2T_4 = 1 + 1 + 2 = 4Example 2:Input: n = 25Output: 1389537 Constraints:0 The answer is guaranteed to fit within a 32-bit integer, ie. answer .  class Solution:..

[DP]99클럽 코테 스터디 38일차 TIL + 0747-min-cost-climbing-stairs

747. Min Cost Climbing StairsEasyYou are given an integer array cost where cost[i] is the cost of ith step on a staircase. Once you pay the cost, you can either climb one or two steps.You can either start from the step with index 0, or the step with index 1.Return the minimum cost to reach the top of the floor. Example 1:Input: cost = [10,15,20]Output: 15Explanation: You will start at index 1.- ..

[Greedy]99클럽 코테 스터디 37일차 TIL + 0455-assign-cookies

455. Assign CookiesEasyAssume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie.Each child i has a greed factor g[i], which is the minimum size of a cookie that the child will be content with; and each cookie j has a size s[j]. If s[j] >= g[i], we can assign the cookie j to the child i, and the child i will be content. Your ..

[Greedy]99클럽 코테 스터디 36일차 TIL + 0409-longest-palindrome

409. Longest PalindromeEasyGiven a string s which consists of lowercase or uppercase letters, return the length of the longest palindrome that can be built with those letters.Letters are case sensitive, for example, "Aa" is not considered a palindrome.Example 1:Input: s = "abccccdd"Output: 7Explanation: One longest palindrome that can be built is "dccaccd", whose length is 7.Example 2:Input: s =..

[BruteForce]99클럽 코테 스터디 35일차 TIL + 백준/Bronze/9094. 수학적 호기심

[Bronze III] 수학적 호기심 - 9094문제 링크성능 요약메모리: 32140 KB, 시간: 4588 ms -> 3797ms분류브루트포스 알고리즘, 수학제출 일자2024년 8월 27일 19:00:11문제 설명두 정수 n과 m이 주어졌을 때, 0 2+b2+m)/(ab)가 정수인 쌍의 개수를 구하는 프로그램을 작성하시오.입력첫째 줄에 테스트 케이스의 개수 T가 주어진다. 각 테스트 케이스는 한 줄로 이루어져 있으며, n과 m이 주어진다. 두 수는 0보다 크고, 100보다 작거나 같다.출력각 테스트 케이스마다 문제의 조건을 만족하는 (a, b)쌍의 개수를 출력한다.  if __name__ == "__main__": case_number = int(input()) case = [] for..