노트(211)
-
[leetcode] 238. 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 any prefix or suffix of nums is guaranteed to fit in a 32-bit integer. You must write an algorithm that runs in O(n) time and without using the division operation. Example 1: Input: nums = [1,2,3,4] Output: [24,12,8,6] Example 2: Input: nums =..
2022.11.08 -
[leetcode] 121. 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 choosing a different day in the future to sell that stock. Return the maximum profit you can achieve from this transaction. If you cannot achieve any profit, return 0. Example 1: Input: prices = [7,1,5,3,6,4] Output: 5 Explanat..
2022.11.08 -
[Foundations of Data Science] 유산소 운동 피트니스 분석 (기술통계 분석 EDA)
유산소 운동 피트니스 케이스 스터디 - 기술 통계(Descriptive Statistics) AdRight의 시장 리서치 팀에게 유산소 운동 피트니스에서 제공된 각 런닝머신 기구에 대한 일반적인 고객들의 프로파일을 확인하라는 업무가 할당되었습니다. 시장 리서치 팀은 고객 특성과 관련하여 제품군에 걸쳐 차이가 있는지 조사하기로 결정했습니다. 팀에서는 과거 3개월 동안 유산소 운동 피트니스 소매점의 런닝머신 기구를 구매한 개인들에대한 데이터를 수집하였습니다. 이 데이터는 CardioGoodFitness.csv 파일입니다. 팀은 다음 고객 변수를 연구하기로 했습니다. 구매된 상품, TM195, TM498, or TM798 성별 나이 교육 수준 관계 상태, 싱글 또는 파트너가 있는지, 연간 가구 소득 고객이 매..
2022.11.06 -
[leetcode] 561. 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. Example 1: Input: nums = [1,4,3,2] Output: 4 Explanation: All possible pairings (ignoring the ordering of elements) are: 1. (1, 4), (2, 3) -> min(1, 4) + min(2, 3) = 1 + 2 = 3 2. (1, 3), (2, 4) -> min(1,..
2022.11.04 -
[leetcode] 15. 3Sum
class Solution(object): def threeSum(self, nums): """ :type nums: List[int] :rtype: List[List[int]] """ res = [] for i in range(len(nums)-2): for j in range(i+1, len(nums)-1): for k in range(j+1, len(nums)): if nums[i] + nums[j] + nums[k] == 0: res.append(sorted([nums[i], nums[j] , nums[k]])) return list(set(map(tuple, res))) => 브루트포스 방식 : Timeout class Solution(object): def threeSum(self, nums)..
2022.11.03 -
[leetcode] 42. Trapping Rain Water
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining. Example 1: Input: height = [0,1,0,2,1,0,1,3,2,1,2,1] Output: 6 Explanation: The above elevation map (black section) is represented by array [0,1,0,2,1,0,1,3,2,1,2,1]. In this case, 6 units of rain water (blue section) are being trapped. Example 2: Input:..
2022.11.02