코딩 테스트(JAVA)/리트코드 11

[문제12][LeetCode] 121. 주식을 사고팔기 가장 좋은 시점

https://leetcode.com/problems/best-time-to-buy-and-sell-stock/description/ You are given an array prices where prices[i] is the price of a given stock on the ith day. 주어진 배열 prices에서 prices[i]는 i번째 날의 특정 주식 가격입니다. 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. 하나의 주식을 사는 날과 미래의 다른 날에 그 주식을 판매하는 것으로 이익을 극대화..

[문제11][LeetCode] 238. 자신을 제외한 배열의 곱

https://leetcode.com/problems/product-of-array-except-self/description/ 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]. 정수 배열 nums가 주어졌을 때, answer[i]가 nums[i]를 제외한 nums의 모든 요소의 곱과 같게 하는 배열 answer를 반환해주세요. The product of any prefix or suffix of nums is guaranteed to fit in a 32-bit integer. nums의 어떤 접두사나 접..

[문제10][LeetCode] 561. 배열 파티션 I

https://leetcode.com/problems/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. 2n개의 정수로 구성된 정수 배열 nums가 주어졌을 때, 이 정수들을 n 쌍의 (a1, b1), (a2, b2), ..., (an, bn)과 같이 그룹화하여 모든 i에 대해 min(ai, bi)의 합이 최대화되도록 합니다. 최대화된 합을 반환하세요. Example 1: Inpu..

[LeetCode] 785. Is Graph Bipartite?

https://leetcode.com/problems/is-graph-bipartite/description/ Is Graph Bipartite? - LeetCode Can you solve this real interview question? Is Graph Bipartite? - There is an undirected graph with n nodes, where each node is numbered between 0 and n - 1. You are given a 2D array graph, where graph[u] is an array of nodes that node u is adjacent to. Mo leetcode.com 각 노드의 번호가 0에서 n-1 사이인 노드가 n개인 방향성 없..