본문 바로가기

알고리즘

[알고리즘] Leetcode #543 이진 트리의 직경 (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 its maximum depth. A binary tree's maximum depth is thGiven the root of a binary tree, return the length of the diameter o.. 더보기
[알고리즘] Leetcode #104 이진 트리의 최대 깊이 (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 its maximum depth. A binary tree's maximum depth is the number of nodes along the longest path from the root node down to .. 더보기
[알고리즘] Leetcode #787 K 경유지 내 가장 저렴한 항공권 (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 문제 설명 There are n cities connected by some number of flights. You are given an array flights where flights[i] = [fromi, toi, pricei] indicates that there is a flight fr.. 더보기
[알고리즘] Leetcode #743 네트워크 딜레이 타임 (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 network of n nodes, labeled from 1 to n. You are also given times, a list of travel times as directed edges times[i] = (ui, vi, wi), where ui is t.. 더보기
[알고리즘] 프로그래머스 가장 큰 수 (Python) programmers.co.kr/learn/courses/30/lessons/42746 코딩테스트 연습 - 가장 큰 수 0 또는 양의 정수가 주어졌을 때, 정수를 이어 붙여 만들 수 있는 가장 큰 수를 알아내 주세요. 예를 들어, 주어진 정수가 [6, 10, 2]라면 [6102, 6210, 1062, 1026, 2610, 2106]를 만들 수 있고, 이중 가장 큰 programmers.co.kr 문제 설명 0 또는 양의 정수가 주어졌을 때, 정수를 이어 붙여 만들 수 있는 가장 큰 수를 알아내 주세요. 예를 들어, 주어진 정수가 [6, 10, 2]라면 [6102, 6210, 1062, 1026, 2610, 2106]를 만들 수 있고, 이중 가장 큰 수는 6210입니다. 0 또는 양의 정수가 담긴 배열 n.. 더보기
[알고리즘] 프로그래머스 K번째 수 (Python) programmers.co.kr/learn/courses/30/lessons/42748 코딩테스트 연습 - K번째수 [1, 5, 2, 6, 3, 7, 4] [[2, 5, 3], [4, 4, 1], [1, 7, 3]] [5, 6, 3] programmers.co.kr 문제 설명 배열 array의 i번째 숫자부터 j번째 숫자까지 자르고 정렬했을 때, k번째에 있는 수를 구하려 합니다. 예를 들어 array가 [1, 5, 2, 6, 3, 7, 4], i = 2, j = 5, k = 3이라면 array의 2번째부터 5번째까지 자르면 [5, 2, 6, 3]입니다. 1에서 나온 배열을 정렬하면 [2, 3, 5, 6]입니다. 2에서 나온 배열의 3번째 숫자는 5입니다. 배열 array, [i, j, k]를 원소로 가.. 더보기
[통계] 알고리즘의 복잡도 (2) - 알고리즘의 여러 차수 지난 게시글에 이어 알고리즘의 여러가지 차수를 계산하여 비교해보고자 한다. 또한, 피보나치 수열을 예제로 재귀적, 반복적 프로그램을 구현해보고 각각의 효율성을 비교할 것이다. 지난 게시글 2020/12/27 - [Machine Learning/#Statistic] - [통계] 알고리즘의 복잡도 (1) [통계] 알고리즘의 복잡도 (1) 대용량 데이터를 효율적으로 처리하기 위해서는 효율적인 알고리즘이 필수적이다. 같은 기능을 수행하는 알고리즘이라도 시간 효율, 메모리 효율은 다를 수 있다. 이번 게시글에서는 벡터의 내 jiwon-lee-it.tistory.com 1/ 알고리즘의 여러 가지 차수 Input size가 커지거나 복잡한 문제일수록 차수 비교가 중요해짐 eg) 외판원 문제 (traveling sal.. 더보기
[통계] 알고리즘의 복잡도 (1) 대용량 데이터를 효율적으로 처리하기 위해서는 효율적인 알고리즘이 필수적이다. 같은 기능을 수행하는 알고리즘이라도 시간 효율, 메모리 효율은 다를 수 있다. 이번 게시글에서는 벡터의 내적을 수행하는 두 가지 다른 알고리즘을 예로 들어 시간 복잡도 및 메모리 비용을 측정해보고자 한다. 또한, 알고리즘의 복잡도를 측정하기 위하여 Big-O라는 차수에 대해 다룰 것이다. 1/ 프로그램의 복잡도: 내적 # 내적 01 innerproduct = function(v, w) { 02sumvalue = 0 03 04 for (i in 1:length(v)){ 05 sumvalue = sumvalue + v[i] * w[i] 06 } 07 return (sumvalue) 08} a/ 시간 복잡도 b/ 메모리 비용 # 향상.. 더보기