[LeetCode] 334. Increasing Triplet Subsequence 해설 및 풀이
·
Study/코딩 테스트
LeetCode 334. Increasing Triplet Subsequence https://leetcode.com/problems/increasing-triplet-subsequence/description/?envType=study-plan-v2&envId=leetcode-75  Given an integer array nums, return true if there exists a triple of indices (i, j, k) such that i Example 1: Input: nums = [1,2,3,4,5] Output: true Explanation: Any triplet where i Example 2: Input: nums = [5,4,3,2,1] Output: false Expla..
[LeetCode] 1071. Greatest Common Divisor of Strings 해설 및 풀이
·
Study/코딩 테스트
LeetCode 1071. Greatest Common Divisor of Stringshttps://leetcode.com/problems/greatest-common-divisor-of-strings/description/?envType=study-plan-v2&envId=leetcode-75  For two strings s and t, we say "t divides s" if and only if s = t + t + t + ... + t + t (i.e., t is concatenated with itself one or more times).Given two strings str1 and str2, return the largest string x such that x divides both..
[백준] 12865번 평범한 배낭 해설 및 풀이 (Python)
·
Study/코딩 테스트
백준 12865번 평범한 배낭https://www.acmicpc.net/problem/12865 문제이 문제는 아주 평범한 배낭에 관한 문제이다.한 달 후면 국가의 부름을 받게 되는 준서는 여행을 가려고 한다. 세상과의 단절을 슬퍼하며 최대한 즐기기 위한 여행이기 때문에, 가지고 다닐 배낭 또한 최대한 가치 있게 싸려고 한다.준서가 여행에 필요하다고 생각하는 N개의 물건이 있다. 각 물건은 무게 W와 가치 V를 가지는데, 해당 물건을 배낭에 넣어서 가면 준서가 V만큼 즐길 수 있다. 아직 행군을 해본 적이 없는 준서는 최대 K만큼의 무게만을 넣을 수 있는 배낭만 들고 다닐 수 있다. 준서가 최대한 즐거운 여행을 하기 위해 배낭에 넣을 수 있는 물건들의 가치의 최댓값을 알려주자.입력첫 줄에 물품의 수 N(..
[LeetCode] 238. Product of Array Except Self 해설 및 풀이 (Python)
·
Study/코딩 테스트
LeetCode 238. Product of Array Except Selfhttps://leetcode.com/problems/product-of-array-except-self/description/?envType=study-plan-v2&envId=leetcode-75 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 any prefix or suffix of nums is guaranteed to fit in a 32-bit integer.You must write an al..
[백준] 11724번 연결 요소의 개수 해설 및 풀이 (Python)
·
Study/코딩 테스트
백준 11724번 연결 요소의 개수https://www.acmicpc.net/problem/11724 문제방향 없는 그래프가 주어졌을 때, 연결 요소 (Connected Component)의 개수를 구하는 프로그램을 작성하시오.입력첫째 줄에 정점의 개수 N과 간선의 개수 M이 주어진다. (1 ≤ N ≤ 1,000, 0 ≤ M ≤ N×(N-1)/2) 둘째 줄부터 M개의 줄에 간선의 양 끝점 u와 v가 주어진다. (1 ≤ u, v ≤ N, u ≠ v) 같은 간선은 한 번만 주어진다.출력첫째 줄에 연결 요소의 개수를 출력한다.문제 유형그래프 이론그래프 탐색너비 우선 탐색깊이 우선 탐색 풀이 방법 도출 무방향 그래프에서 한 정점에서 다른 정점으로 경로가 존재하면 같은 연결 요소에 속합니다.경로가 전혀 없는 정점..