본문 바로가기

Algorithm

(239)
스택/큐 01 - 다리를지나는트럭, 프로그래머스, 알고리즘, Programmers, Stack, Queue, Hash, 코딩테스트, Algorithm, 풀이과정, Leetcode, 릿코드, 코딩테스트, Tech interview # Process (list) # 1. Input prices list # 2. Iterate i from begin to the end # 2.1. Iterate j from i to the end # 2.1.1. Check if [j] is smaller than [i] # 2.1.1.1. If so - it's done # 2.1.2. Count # 2.2. Add to answer_list # 3. Return answer_list # 왜 스택 문제인지? 봐야함. 굳이? def solution(prices): answer_list = [] for i in range(0, len(prices)): isDone = False count = 0 j = i while (j < len(prices) and..
해시 04 - 베스트앨범, 프로그래머스, 알고리즘, Programmers, Stack, Queue, Hash, 코딩테스트, Algorithm, 풀이과정, Leetcode, 릿코드, 코딩테스트, Tech interview # 문제 설명이 불친절함 # Process # 1. Input genres and plays arrays # 2. 딕셔너리 만든다. # 2.1. 장르별로 총 플레이 횟수가 있는 딕셔너리 만든다. { str, int } # 2.2. 장르별 딕셔너리 안에, 노래별로 플레이횟수와 인덱스가 있는 딕셔너리 만든다. { str, [int, int] } # 3. 장르별 총 플레이 딕셔너리 플레이 수에 따라 내림차순으로 정렬 # 4. 정렬한 장르 이름을 키로 노래플레이횟수와 인덱스 리스트가 있는 딕셔너리를 반복한다. # 4.1. 노래별 플레이 횟수 + 인덱스 리스트를 노래별 플레이 횟수의 내림차순 기준으로 정렬한다. # 4.2. 정렬한 노래별플레이횟수 + 인덱스 리스트에서, 2개 이하로 뽑아내서 결과물 앨범에 넣는다...
해시 03 - 위장, 프로그래머스, 알고리즘, Programmers, Stack, Queue, Hash, 코딩테스트, Algorithm, 풀이과정, Leetcode, 릿코드, 코딩테스트, Tech interview # Process # 1. Input clothes [[name, kind]...] # 2. Make dictionary {kind, count_clothes} # 3. Get sum of multiplication of (count_clothes + 1) # 4. Return (sum - 1) for subtract wearing nothing def solution(clothes): dictClothes = {} for i in range(0, len(clothes)): if clothes[i][1] in dictClothes: dictClothes[clothes[i][1]] += 1 else: dictClothes[clothes[i][1]] = 1 mul = 1 for value in dictClo..
해시 02 - 전화번호 목록, 프로그래머스, 알고리즘, Programmers, Stack, Queue, Hash, 코딩테스트, Algorithm, 풀이과정, Leetcode, 릿코드, 코딩테스트, Tech interview # 전화번호부에 적힌 전화번호 중, 한 번호가 다른 번호의 접두어인 경우가 있는지 확인하려 합니다. # 전화번호가 다음과 같을 경우, 구조대 전화번호는 영석이의 전화번호의 접두사입니다. # 구조대 : 119 # 박준영 : 97 674 223 # 지영석 : 11 9552 4421 # 전화번호부에 적힌 전화번호를 담은 배열 phone_book 이 solution 함수의 매개변수로 주어질 때, 어떤 번호가 다른 번호의 접두어인 경우가 있으면 false를 그렇지 않으면 true를 return 하도록 solution 함수를 작성해주세요. # Process # 1. Input phone_book array # 2. Sort using length of elements # 3. Iterate from begin to..
해시 01 - 완주하지 못한 선수, 프로그래머스, 알고리즘, Programmers, Stack, Queue, Hash, 코딩테스트, Algorithm, 풀이과정, Leetcode, 릿코드, 코딩테스트, Tech interview 간만에 쌓인 것들 다시 업로드를.. # 참가자의 각 이름과 이름이 몇번 나왔는지를 확인해서 해시를 만들고, # 완주자로 위의 해시의 카운트를 빼서 없애준다. # 남은 참가자가 있으면 그 자가 범인! # 1. Input participant and completion arrays # 2. Make participant Hash # 3. Iterate completion array # 3.1. Check Hash # 3.1.1. If Hash has Name of completion, reduce Count. # 3.1.2. If Hash doesn't have Name or Count == 0, then remove that Name Hash. # 4. Return remained participant N..
LeetCode #728 SelfDividingNumbers. Algorithm,알고리즘,LeetCode,Codefights,CodeSignal,코드파이트,코드시그널,예제,그래프,Graph,example,c++,java,재귀,recursive,datastructure,techinterview,coding,코딩인터뷰,기술면접, 데이터.. LeetCode #728 SelfDividingNumbers. Algorithm,알고리즘,LeetCode,Codefights,CodeSignal,코드파이트,코드시그널,예제,그래프,Graph,example,c++,java,재귀,recursive,datastructure,techinterview,coding,코딩인터뷰,기술면접, 데이터베이스, sql, query, 쿼리 It's been a long time.. 아주 오랜만에.. Runtime: 0 ms, faster than 100.00% of C++ online submissions for Self Dividing Numbers. Memory Usage: 6.3 MB, less than 97.68% of C++ online submissions for S..
LeetCode #1030 MatrixCellsInDistanceOrder. Algorithm,알고리즘,LeetCode,Codefights,CodeSignal,코드파이트,코드시그널,예제,그래프,Graph,example,c++,java,재귀,recursive,datastructure,techinterview,coding,코딩인터뷰,기술면접, .. LeetCode #1030 MatrixCellsInDistanceOrder. Algorithm,알고리즘,LeetCode,Codefights,CodeSignal,코드파이트,코드시그널,예제,그래프,Graph,example,c++,java,재귀,recursive,datastructure,techinterview,coding,코딩인터뷰,기술면접, 데이터베이스, sql, query, 쿼리 Need to think bout enhancing performance Runtime: 896 ms, faster than 5.22% of C++ online submissions for Matrix Cells in Distance Order. Memory Usage: 23.9 MB, less than 57.50% of C++..
LeetCode #922 SortArrayByParity2. Algorithm,알고리즘,LeetCode,Codefights,CodeSignal,코드파이트,코드시그널,예제,그래프,Graph,example,c++,java,재귀,recursive,datastructure,techinterview,coding,코딩인터뷰,기술면접, 데이터.. LeetCode #922 SortArrayByParity2. Algorithm,알고리즘,LeetCode,Codefights,CodeSignal,코드파이트,코드시그널,예제,그래프,Graph,example,c++,java,재귀,recursive,datastructure,techinterview,coding,코딩인터뷰,기술면접, 데이터베이스, sql, query, 쿼리 Runtime: 88 ms, faster than 49.29% of C++ online submissions for Sort Array By Parity II. Memory Usage: 14.3 MB, less than 12.50% of C++ online submissions for Sort Array By Parity II. LeetCode..