전체 글 278

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

문제 설명혜민이는 요즘 모스 부호에 관심이 많아졌다. 모스 부호는 짧은 신호와 긴 신호를 적절히 조합하여 문자 기호를 표기하는 방식이다. 각 문자를 나타내는 방식은 미리 정해져 있는데, 예를 들어, 짧은 신호를 '.', 긴 신호를 '-'로 나타낸다면, 모스 부호로 알파벳 'A'는 '.-', 숫자 1은 '.----'와 같이 표기할 수 있다. 모스 부호를 알고 있으면 위험한 상황에서 구조 요청을 하는 데 유용할 것 같아, 혜민이는 평상시에 친구들과 연락을 주고받을 때도 모스 부호를 사용하려고 한다. 혜민이는 친구들이 보내온 모스 부호를 올바르게 해독했는지 바로바로 확인하고 싶어졌다. 알파벳 A-Z, 숫자 0-9, 기호 ',', '.', '?', ':', '-', '@'로 이루어진 길이 N$N$인 문자열을 변..

[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 =..