알고리즘 4

[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] - 두 수의 합

문제) 덧셈하여 타겟을 만들 수 있는 배열의 두 숫자 인덱스를 리턴하라. 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..

[백준] 2961번 도영이가 만든 맛있는 음식 - 파이썬

https://www.acmicpc.net/problem/2961 2961번: 도영이가 만든 맛있는 음식 첫째 줄에 재료의 개수 N(1 ≤ N ≤ 10)이 주어진다. 다음 N개 줄에는 그 재료의 신맛과 쓴맛이 공백으로 구분되어 주어진다. 모든 재료를 사용해서 요리를 만들었을 때, 그 요리의 신맛과 쓴맛은 www.acmicpc.net solution) 모든 경우의 수를 따져서 계산하는 방법 사용 1. 입력 받아오기 n = int(input()) flavor = [list(map(int,input().split())) for _ in range(n)] 2. 재귀함수를 사용해 모든 경우의 수 따지기 - answer을 크게 설정해 신맛과 쓴맛의 차이가 가장 작은 요리 출력 def recur(idx, sour ,..