본문 바로가기

알고리즘

[알고리즘] Leetcode #687 가장 긴 동일 값의 경로 (Python) ↓↓↓ 아래는 내 리트코드 계정 ↓↓↓ leetcode.com/Jiwon_Lee/ Jiwon Lee - LeetCode Profile Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제 설명 Given the root of a binary tree, return the length of the longest path, where each node in the path has the same value. This path may or may not pass through the .. 더보기
[알고리즘] Leetcode #509 피보나치 수 (Python) ↓↓↓ 아래는 내 리트코드 계정 ↓↓↓ leetcode.com/Jiwon_Lee/ Jiwon Lee - LeetCode Profile Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제 설명 The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting .. 더보기
[알고리즘] Leetcode #136 싱글 넘버 (Python) ↓↓↓ 아래는 내 리트코드 계정 ↓↓↓ leetcode.com/Jiwon_Lee/ Jiwon Lee - LeetCode Profile Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제 설명 Given a non-empty array of integers nums, every element appears twice except for one. Find that single one. You must implement a solution with a linear runtime co.. 더보기
[알고리즘] Leetcode #122 주식을 사고팔기 가장 좋은 시점 2 (Python) ↓↓↓ 아래는 내 리트코드 계정 ↓↓↓ leetcode.com/Jiwon_Lee/ Jiwon Lee - LeetCode Profile Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제 설명 You are given an array prices where prices[i] is the price of a given stock on the ith day. Find the maximum profit you can achieve. You may complete as many tran.. 더보기
[알고리즘] 그리디 - 배낭 문제 (Python) 문제 설명 배낭에 담을 수 있는 무게의 최댓값이 정해져있고, 각각의 짐의 가치($ 단위)와 무게(kg 단위)가 있는 짐들을 배낭에 넣을 때 가치의 합이 최대가 되도록, 즉 $(달러)의 가치가 최대가 되도록 짐을 고르는 방법을 찾기 입출력 예 Input: cargo = [ (4, 12), (2, 1), (10, 4), (1, 1), (2, 2), ] Output: 17.333333333333332 Code def fractional_knapsack(cargo): capacity = 15 pack = [] # 단가 계산 역순 정렬 for c in cargo: pack.append((c[0] / c[1], c[0], c[1])) pack.sort(reverse = True) # 단가 순 그리디 계산 total.. 더보기
[알고리즘] Leetcode #424 가장 긴 반복 문자 대체 (Python) ↓↓↓ 아래는 내 리트코드 계정 ↓↓↓ leetcode.com/Jiwon_Lee/ Jiwon Lee - LeetCode Profile Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제 설명 You are given a string s and an integer k. You can choose any character of the string and change it to any other uppercase English character. You can perform this.. 더보기
[알고리즘] Leetcode #76 부분 문자열이 포함된 최소 윈도우 (Python) ↓↓↓ 아래는 내 리트코드 계정 ↓↓↓ leetcode.com/Jiwon_Lee/ Jiwon Lee - LeetCode Profile Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제 설명 Given two strings s and t of lengths m and n respectively, return the minimum window in s which will contain all the characters in t. If there is no such window i.. 더보기
[알고리즘] Leetcode #239 최대 슬라이딩 윈도우 (Python) ↓↓↓ 아래는 내 리트코드 계정 ↓↓↓ leetcode.com/Jiwon_Lee/ Jiwon Lee - LeetCode Profile Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제 설명 You are given an array of integers nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see t.. 더보기