일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
- 맥북
- 편스토랑
- 프로그래머스 파이썬
- Kaggle
- 캐치카페
- 코로나19
- programmers
- 백준
- gs25
- ChatGPT
- Baekjoon
- 자연어처리
- 우분투
- Docker
- 금융문자분석경진대회
- 프로그래머스
- 더현대서울 맛집
- Git
- SW Expert Academy
- dacon
- AI 경진대회
- 데이콘
- ubuntu
- Real or Not? NLP with Disaster Tweets
- leetcode
- 파이썬
- PYTHON
- hackerrank
- github
- 편스토랑 우승상품
- Today
- Total
목록
반응형
Programming/코딩 1일 1문제 (1013)
솜씨좋은장씨

You are given a string containing characters A and B only. Your task is to change it into a string such that there are no matching adjacent characters. To do this, you are allowed to delete zero or more characters in the string. Your task is to find the minimum number of required deletions. For example, given the string s = AABAAB, remove an A at positions 0 and 3 to make s = ABAB in 2 deletions..

Mark and Jane are very happy after having their first child. Their son loves toys, so Mark wants to buy some. There are a number of different toys lying in front of him, tagged with their prices. Mark has only a certain amount to spend, and he wants to maximize the number of toys he buys with this money. Given a list of prices and an amount to spend, what is the maximum number of toys Mark can b..

Every email consists of a local name and a domain name, separated by the @ sign. For example, in alice@leetcode.com, alice is the local name, and leetcode.com is the domain name. Besides lowercase letters, these emails may contain '.'s or '+'s. If you add periods ('.') between some characters in the local name part of an email address, mail sent there will be forwarded to the same address withou..

1일 1문제 46일차! 오늘의 문제는 쉬운 계단수입니다. 10844번: 쉬운 계단 수 첫째 줄에 정답을 1,000,000,000으로 나눈 나머지를 출력한다. www.acmicpc.net Solution inputNum = int(input()) nc = [[0]*10 for _ in range(inputNum+1)] ans, mod = 0, 1000000000 for i in range(1, 10): nc[1][i] = 1 for i in range(2, inputNum+1): for j in range(0, 10): if j > 0: nc[i][j] += nc[i-1][j-1] if j < 9: nc[i][j] += nc[i-1][j+1] nc[i][j] %= mod # print(nc) print(s..

Harold is a kidnapper who wrote a ransom note, but now he is worried it will be traced back to him through his handwriting. He found a magazine and wants to know if he can cut out whole words from it and use them to create an untraceable replica of his ransom note. The words in his note are case-sensitive and he must use only whole words available in the magazine. He cannot use substrings or con..

코딩 1일 1문제 42일차! SW Expert Academy SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요! swexpertacademy.com 이 문제는 주어진 문자열을 가지고 앞과 뒤에서 하나씩 알파벳을 뽑아서 문자열을 만드는데 사전순으로 가장 빠른 문자열을 만드는 것이 목표인 문제입니다. 11회차만에.... 장장 12시간에 걸친 고민 끝에 풀었습니다. 처음부터 하나하나 손으로 적어가면서 풀어볼껄 하는 후회가 드는 문제였습니다. Solution input_num = int(input()) for i in range(input_num): input_text = str(input()) text = list(input_text) answer = [] front = 0 end = ..

A bracket is considered to be any one of the following characters: (, ), {, }, [, or ]. Two brackets are considered to be a matched pair if the an opening bracket (i.e., (, [, or {) occurs to the left of a closing bracket (i.e., ), ], or }) of the exact same type. There are three types of matched pairs of brackets: [], {}, and (). A matching pair of brackets is not balanced if the set of bracket..

1일 1문제 42일차! 오늘의 문제는 백준의 2xn타일링입니다. 11726번: 2×n 타일링 2×n 크기의 직사각형을 1×2, 2×1 타일로 채우는 방법의 수를 구하는 프로그램을 작성하시오. 아래 그림은 2×5 크기의 직사각형을 채운 한 가지 방법의 예이다. www.acmicpc.net Solution n = int(input()) def answer(n): if n == 1: fiboNum = 1 elif n == 2: fiboNum = 2 elif n >= 3: fibo = [0] * (n) fibo[0] = 1 fibo[1] = 2 for i in range(2, n): fibo[i] = fibo[i-1] + fibo[i-2] fiboNum = fibo[n-1] % 10007 return fiboN..

오늘은 지원했던 회사에서 감사하게도 면접을 볼 기회를 주셔서 면접을 보러 다녀왔습니다. 면접 시 문제로 나왔던 문제를 다시 풀어보니 어려운 문제가 아니었지만 면접시간에 조건에 맞는 코드를 작성하지 못하여 면접이 끝나고 다시 도전해보았습니다. 먼저 문제는 다음과 같습니다. 문제 다음과 같이 정렬된 리스트 3개가 주어졌을때 3개의 리스트에 모두 존재하는 값을 찾아 출력하시오. (단, 정렬된 리스트라는 조건을 활용하여 최대한 효율적인 코드를 작성하시오) Sample input a = [ 1, 3, 5, 7, 9, 13, 15 ] b = [ 4, 5, 6, 8, 13 ] c = [ 5, 8, 13, 19 ] Sample output [ 5, 13 ] 저는 이문제를 보고 처음에는 in 을 사용하여 문제를 풀었습니..

코딩 1일 1문제 41일차! 작심 3일로 끝날것 같았던 문제 풀이가 41일차까지 왔습니다. 오늘의 문제는 세제곱근을 찾아라입니다. SW Expert Academy SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요! swexpertacademy.com 이 문제는 입력 받은 수가 세제곱의 수면 세제곱근의 값을 출력하고 그렇지 않으면 -1을 출력하는 문제입니다. Solution loop_num = int(input()) pow3_dic = {} for i in range(pow(10, 6) + 1): pow3_dic[pow(i, 3)] = i keys = pow3_dic.keys() for i in range(loop_num): input_num = int(input()) if inpu..

코딩 1일 1문제 40일차! 오늘의 문제는 삼성 SW EXPERT의 염라대왕의 이름정렬입니다. SW Expert Academy SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요! swexpertacademy.com Solution count = 1 loop_num = int(input()) for i in range(loop_num): input_num = int(input()) input_str_list = [] for i in range(input_num): string = str(input()) input_str_list.append((string, len(string))) # print(input_str_list) input_str_list = list(set(input_s..

Given an array of integers, calculate the fractions of its elements that are positive, negative, and are zeros. Print the decimal value of each fraction on a new line. Note: This challenge introduces precision problems. The test cases are scaled to six decimal places, though answers with absolute error of up to 10^(-4) are acceptable. For example, given the array arr = [1, 1, 0, -1, -1 ] there a..

Given a square matrix, calculate the absolute difference between the sums of its diagonals. For example, the square matrix arr is shown below: 1 2 3 4 5 6 9 8 9 The left-to-right diagonal = 1 + 5 + 9 = 15. The right to left diagonal = 3 + 5 + 9 = 17. Their absolute difference is | 15 - 17 | = 2. Function description Complete the diagonalDifference function in the editor below. It must return an ..

Given two strings, determine if they share a common substring. A substring may be as small as one character. For example, the words "a", "and", "art" share the common substring a. The words "be" and "cat" do not share a substring. Function Description Complete the function twoStrings in the editor below. It should return a string, either YES or NO based on whether the strings share a common subs..

Starting with a 1-indexed array of zeros and a list of operations, for each operation add a value to each of the array element between two given indices, inclusive. Once all operations have been performed, return the maximum value in your array. For example, the length of your array of zeros n = 10. Your list of queries is as follows: a b k 1 5 3 4 8 7 6 9 1 Add the values of k between the indic..

Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word (last word means the last appearing word if we loop from left to right) in the string. If the last word does not exist, return 0. Note: A word is defined as a maximal substring consisting of non-space characters only. Example: Input: "Hello World" Output: 5 Solution class Soluti..

You are given an unordered array consisting of consecutive integers [1, 2, 3, ..., n] without any duplicates. You are allowed to swap any two elements. You need to find the minimum number of swaps required to sort the array in ascending order. For example, given the array arr = [ 7, 1, 3, 2, 4, 5, 6, ] we perform the following steps: i arr swap (indices) 0 [7, 1, 3, 2, 4, 5, 6] swap (0,3) 1 [2, ..

Consider the following version of Bubble Sort: for (int i = 0; i a[j + 1]) { swap(a[j], a[j + 1]); } } } Given an array of integers, sort the array in ascending order using the Bubble Sort algorithm above. Once sorted, print the following three lines: Array is sorted in numSwaps swa..

Emma is playing a new mobile game that starts with consecutively numbered clouds. Some of the clouds are thunderheads and others are cumulus. She can jump on any cumulus cloud having a number that is equal to the number of the current cloud plus 1 or 2. She must avoid the thunderheads. Determine the minimum number of jumps it will take Emma to jump from her starting postion to the last cloud. It..

Lilah has a string, s, of lowercase English letters that she repeated infinitely many times. Given an integer, n, find and print the number of letter a's in the first n letters of Lilah's infinite string. For example, if the string s = 'abcac' and n = 10, the substring we consider is abcacabcac, the first 10 characters of her infinite string. There are 4 occurrences of a in the substring. Functi..

Gary is an avid hiker. He tracks his hikes meticulously, paying close attention to small details like topography. During his last hike he took exactly n steps. For every step he took, he noted if it was an uphill, U , or a downhill, D step. Gary's hikes start and end at sea level and each step up or down represents a 1 unit change in altitude. We define the following terms: A mountain is a seque..

John works at a clothing store. He has a large pile of socks that he must pair by color for sale. Given an array of integers representing the color of each sock, determine how many pairs of socks with matching colors there are. For example, there are n = 7 socks with colors ar = [1, 2, 1, 2, 1, 3, 2] . There is one pair of color 1 and one of color 2. There are three odd socks left, one of each c..

Given a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time complexity must be in O(n). Example 1: Input: [3, 2, 1] Output: 1 Explanation: The third maximum is 1. Example 2: Input: [1, 2] Output: 2 Explanation: The third maximum does not exist, so the maximum (2) is returned instead. Example 3: Input: [2, 2, 3, 1] ..

Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. Example: Input: 1->2->4, 1->3->4 Output: 1->1->2->3->4->4 Solution # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def mergeTwoLists(self, l1: ListNode, l2: ListNode) -> List..

Given an input string, reverse the string word by word. Example 1: Input: "the sky is blue" Output: "blue is sky the" Example 2: Input: " hello world! " Output: "world! hello" Explanation: Your reversed string should not contain leading or trailing spaces. Example 3: Input: "a good example" Output: "example good a" Explanation: You need to reduce multiple spaces between two words to a single spa..

1일 1문제 25일차! 오늘의 문제는 백준의 접미사 배열입니다. 오늘은 이전에 풀었던 문제를 다시 풀어보았습니다. 11656번: 접미사 배열 첫째 줄에 문자열 S가 주어진다. S는 알파벳 소문자로만 이루어져 있고, 길이는 1,000보다 작거나 같다. www.acmicpc.net 이전 제출 코드 string = input() string = list(string) myStrings = [] while len(string) > 0: myStrings.append(str(string)) string.pop(0) myStrings = set(myStrings) new = [] for word in myStrings: word = word.replace('[', '') word = word.replace(',',..

1일 1문제 24일차! 오늘의 문제는 프로그래머스 스택 큐 프린터입니다. 코딩테스트 연습 - 프린터 | 프로그래머스 일반적인 프린터는 인쇄 요청이 들어온 순서대로 인쇄합니다. 그렇기 때문에 중요한 문서가 나중에 인쇄될 수 있습니다. 이런 문제를 보완하기 위해 중요도가 높은 문서를 먼저 인쇄하는 프린터를 개발했습니다. 이 새롭게 개발한 프린터는 아래와 같은 방식으로 인쇄 작업을 수행합니다. 1. 인쇄 대기목록의 가장 앞에 있는 문서(J)를 대기목록에서 꺼냅니다. 2. 나머지 인쇄 대기목록에서 J보다 중요도가 높은 문서가 한 개라도 존재하면 J를 대기목록의 가장 마지막에 programmers.co.kr 첫번째 시도 def solution(priorities, location): answer = 0 pri_d..

There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). You may assume nums1 and nums2 cannot be both empty. Example 1: nums1 = [1, 3] nums2 = [2] The median is 2.0 Example 2: nums1 = [1, 2] nums2 = [3, 4] The median is (2 + 3)/2 = 2.5 Solution class Solution: def findMedianSortedA..

1일 1문제 22일차! 오늘의 문제는 프로그래머스의 완전탐색 소수찾기입니다! 코딩테스트 연습 - 소수 찾기 | 프로그래머스 한자리 숫자가 적힌 종이 조각이 흩어져있습니다. 흩어진 종이 조각을 붙여 소수를 몇 개 만들 수 있는지 알아내려 합니다. 각 종이 조각에 적힌 숫자가 적힌 문자열 numbers가 주어졌을 때, 종이 조각으로 만들 수 있는 소수가 몇 개인지 return 하도록 solution 함수를 완성해주세요. 제한사항 numbers는 길이 1 이상 7 이하인 문자열입니다. numbers는 0~9까지 숫자만으로 이루어져 있습니다. 013은 0, 1, 3 숫자가 적힌 종이 programmers.co.kr itertools의 permutation함수와 이전에 풀었던 에라토스테네스의 체 문제를 활용하여 ..

1일 1문제 21일차! 오늘의 문제는 프로그래머스 베스트 앨범 입니다. 코딩테스트 연습 - 베스트앨범 | 프로그래머스 스트리밍 사이트에서 장르 별로 가장 많이 재생된 노래를 두 개씩 모아 베스트 앨범을 출시하려 합니다. 노래는 고유 번호로 구분하며, 노래를 수록하는 기준은 다음과 같습니다. 속한 노래가 많이 재생된 장르를 먼저 수록합니다. 장르 내에서 많이 재생된 노래를 먼저 수록합니다. 장르 내에서 재생 횟수가 같은 노래 중에서는 고유 번호가 낮은 노래를 먼저 수록합니다. 노래의 장르를 나타내는 문자열 배열 genres와 노래별 재생 횟수를 나타내는 정수 배열 play programmers.co.kr 첫번째 시도 dictionary를 활용해보기로 했습니다. def solution(genres, play..