분류 전체보기 100

[leetcode 225.python] 큐를 이용한 스택 구현 (Implement Stack using Queues) 풀이

https://leetcode.com/problems/implement-stack-using-queues/ Implement Stack using Queues - LeetCode Can you solve this real interview question? Implement Stack using Queues - Implement a last-in-first-out (LIFO) stack using only two queues. The implemented stack should support all the functions of a normal stack (push, top, pop, and empty). Implement the leetcode.com 문제 Implement a last-in-first..

Algorithm/LeetCode 2024.01.04

[leetcode 561.python] 배열 파티션 1(Array-partition 1) 풀이

https://leetcode.com/problems/array-partition/ Array Partition - LeetCode Can you solve this real interview question? 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. leetcode.com 문제 Given an integer array nums of 2n integers, group t..

Algorithm/LeetCode 2024.01.03

[leetcode 49.python] 그룹 애너그램 (Group Anagrams) 풀이

https://leetcode.com/problems/group-anagrams/ Group Anagrams - LeetCode Can you solve this real interview question? Group Anagrams - Given an array of strings strs, group the anagrams together. You can return the answer in any order. An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase leetcode.com 문제 Given an array of strings strs, group the anagrams to..

Algorithm/LeetCode 2024.01.03

[Algorithm] 알고리즘 공부를 시작하며 / 알고리즘 개요

알고리즘을 공부하는 이유 같은 문제를 풀더라도 더 시간적으로/공간적으로 효율적인 방법을 쓰기 위해서. 알고리즘의 타겟 두 가지 1. 시간 복잡도 시간 복잡도를 낮춰 연산 횟수를 최대한 줄이자. 2. 공간 복잡도 사용하는 메모리를 줄이자. => 어떻게 하면 시간 복잡도/공간 복잡도를 줄이며 문제를 해결할 수 있을까? 가 알고리즘을 공부하는 이유라고 할 수 있겠다. 그렇다면 좋은 알고리즘이란 ? 1. 입력값이 늘어나도 걸리는 시간이 덜 늘어나는 알고리즘 2. 입력값이 늘어나도 걸리는 공간이 덜 늘어나는 알고리즘 기억해야 할 것 1. 입력값에 비례해서 얼마나 늘어날지 파악해보자. 1? N? N제곱? 2. 공간 복잡도 보다는 시간 복잡도를 더 줄이기 위해 고민하자. 3. 최악의 경우에 시간이 얼마나 소요될지 (..

Algorithm 2024.01.03