코딩테스트 (Coding Test) 22

[프로그래머스]- 기능개발

문제) https://school.programmers.co.kr/learn/courses/30/lessons/42586 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 입력 progresses = [93, 30, 55] , speeds = [1,30,5] 출력 [2,1] 풀이) 문제이해 첫 번째 기능은 93% 가 완료되어 있고 하루에 1%씩 작업이 가능하므로 7일간 작업 후 배포가 가능하다. 두 번째 기능은 30% 가 완료되어 있고 하루에 30% 씩 작업이 가능하므로 3일간 작업 후 배포가 가능하다. 하지만 이전 첫 번째 기능이 아직 완성된 상태가 아니기..

[LeetCode] - 일일온도(파이썬)

풀이) 매일의 화씨 온도 리스트 T를 입력받아서, 더 따뜻한 날씨를 위해서 며칠을 더 기다려야 하는지 출력하라. https://leetcode.com/problems/daily-temperatures/ Daily Temperatures - LeetCode Can you solve this real interview question? Daily Temperatures - Given an array of integers temperatures represents the daily temperatures, return an array answer such that answer[i] is the number of days you have to wait after the ith day to get a warmer..

[LeetCode] - 유효한 괄호

문제) 괄호로 된 입력값이 올바른지 판별하라 https://leetcode.com/problems/valid-parentheses/ Valid Parentheses - LeetCode Can you solve this real interview question? Valid Parentheses - Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: 1. Open brackets must be closed by the sam leetcode.com ▶ 입력 [](){} ▶ 출력 true 풀이)..

[LeetCode] - 자신을 제외한 배열의 곱

문제) 배열을 입력받아 ouput[i]가 자신을 제외한 나머지 모든 요소의 곱셈결과가 되도록 출력하라 https://leetcode.com/problems/product-of-array-except-self/description/ Product of Array Except Self - LeetCode Can you solve this real interview question? Product of Array Except Self - Given an integer array nums, return an array answer such that answer[i] is equal to the product of all the elements of nums except nums[i]. The product of..

[LeetCode] - 주식을 사고팔기 가장 좋은 시점

문제) 한 번의 거래로 낼 수 있는 최대 이익을 산출하라 https://leetcode.com/problems/best-time-to-buy-and-sell-stock/description/ Best Time to Buy and Sell Stock - LeetCode Can you solve this real interview question? Best Time to Buy and Sell Stock - You 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..

[LeetCode] - 배열 파티션 I

문제) n개의 페어를 이용한 min(a,b)의 합으로 만들 수 있는 가장 큰 수를 출력하라 https://leetcode.com/problems/array-partition/description/ Array Partition - LeetCode Can you solve this real interview question? Array Partition - Given an integer array nums of 2n integers, group these integers into n pairs (a1, b1), (a2, b2), ..., (an, bn) such that the sum of min(ai, bi) for all i is maximized. Return the maximized sum. leet..

[LeetCode] - 세 수의 합

문제) 배열의 입력받아 합으로 0을 만들 수 있는 3개의 엘리먼트를 출력해라 https://leetcode.com/problems/3sum/description/ 3Sum - LeetCode Can you solve this real interview question? 3Sum - Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0. Notice that the solution set must not contain du leetcode.com 풀이) 1.브루트 포스 먼저 브루트포스..

[LeetCode] - 두 수의 합

문제) 덧셈하여 타겟을 만들 수 있는 배열의 두 숫자 인덱스를 리턴하라. https://leetcode.com/problems/two-sum/description/ Two Sum - LeetCode Can you solve this real interview question? Two Sum - Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not leetcode.com 풀이) 1. 브루트포스로 풀기 c..

[프로그래머스] Lv1 문제풀이

1. 문제 https://school.programmers.co.kr/learn/courses/30/lessons/134240 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 💡이해 ⇒ food = [1,3,4,6] 일 경우 1칼로리 음식이 3개, 2칼로리 음식이 4개, 3칼로리 음식이 6개 이므로 1223330333221 로 결과가 나타나야 한다. - 양쪽에 배열되므로 2로 나눈 몫만큼 음식을 배열하기 - 중간에 0(물)을 추가하고, 나머지는 reverse해서 붙여주기 def solution(food) : temp = '' for i in range(1,..

[프로그래머스] Lv1 문제풀이

1. 추억점수 💡dict 함수와 zip을 사용해 쉽게 풀이할 수 있다. 아래 코드는 key를 name, value를 yearning으로 하여 딕셔너리를 생성했다. name = ["may", "kein", "kain", "radi"] yearning = [5, 10, 1, 3] dictionary = dict(zip(name,yearning)) 2. 가운데 글자 가져오기 💡리스트 slicing에 관한 개념이 필요하다. ⇒ list[start:end+1] 로 원하는 위치에 있는 것을 가져올 수 있다 a= ['a','b','c','d','e'] a[2:4] #실행결과 ['b','c'] #인덱스를 1~3까지 값을 거꾸로 가져오기 a[3:0:-1] #실행결과 ['d','c','b'] 3. 수박수박수박수박수박수? ..