Alogorithm
-
[Algorithm] LeetCode - 3. Longest Substring Without Repeating Characters (Hash Table, String, Sliding Window)Alogorithm 2022. 7. 28. 00:14
LeetCode 문제입니다. [문제설명] Given a string s, find the length of the longest substring without repeating characters. 번역) Given a string s, find the length of the longest substring without repeating characters. 주어는 문자열 s에서, 반복되지 않은 문자가 없는 가장 긴 문자열의 길이를 구하시오 Topic: Hash Table, String, Sliding Window Level: Medium Accepted 3,608,442 / Submissions 10,756,223 [제한사항] 0 subStr === [...new Set(subStr.split("..
-
[Algorithm] LeetCode - 2. Add Two Numbers (LinkedList, Math, Recursion)Alogorithm 2022. 7. 2. 19:59
LeetCode 문제입니다. [문제설명] You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list. You may assume the two numbers do not contain any leading zero, except the number 0 itself. 번역) 두 개의 음이 아닌 정수를 나타내는 두 개의 비어 있지 않은 연결 목록이 제공됩니다. 숫자는 ..
-
[Algorithm] LeetCode - 49. Group Anagrams (Hash Table, Sorting, String)Alogorithm 2022. 4. 18. 21:19
LeetCode 문제입니다. [문제설명] 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, typically using all the original letters exactly once. 번역) 문자열 배열이 주어지면 "Anagram은"을 함께 그룹화하십시오. 어떤 순서로든 답변을 반환할 수 있습니다. "Anagram"은 일반적으로 모든 원래 문자를 정확히 한 번 사용하여 다른 단어 또는 구의 문자를 재배..
-
[Algorithm] LeetCode - 229. Majority Element II, [Array, Hash, Sorting]Alogorithm 2022. 4. 18. 21:02
LeetCode 문제입니다. [문제설명] Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. 번역) 크기가 n인 정수 배열이 주어지면 ⌊ n/3 ⌋번 이상 나타나는 모든 요소를 찾습니다. Topic: Array, Hash, Sorting, Counting Level: Medium Accepted 282,193 / Submissions 668,104 [제한사항] 1 threshold) .map(item => Number(item[0])) }; Idea: 1. nums 배열에서 받은 element를 Key로 하고 count를 value로 할 object 생성 2. threshold 계산 3. tmpOb..
-
[Algorithm] LeetCode - 102. Binary Tree Level Order Traversal (BFS)Alogorithm 2022. 2. 13. 19:56
LeetCode 문제입니다. [문제설명] Given the root of a binary tree, return the level order traversal of its nodes' values. (i.e., from left to right, level by level). 번역) 이진 트리의 루트가 주어지면 노드 값의 레벨 순서 순회를 반환합니다. (즉, 왼쪽에서 오른쪽으로, 레벨별로). Topic: Tree, Breadth First Search, Binary Tree Level: Medium Accepted 1,127,671 / Submissions 1,873,375 [제한사항] The number of nodes in the tree is in the range [0, 2000]. -1000
-
[Algorithm] LeetCode - 113. Path Sum II (DFS)Alogorithm 2022. 2. 13. 19:48
LeetCode 문제입니다. [문제설명] Given the root of a binary tree and an integer targetSum, return all root-to-leaf paths where the sum of the node values in the path equals targetSum. Each path should be returned as a list of the node values, not node references. A root-to-leaf path is a path starting from the root and ending at any leaf node. A leaf is a node with no children. 번역) Binary Tree의 root와 정수 t..
-
[Algorithm] 시간 복잡도Alogorithm 2022. 1. 23. 20:54
개념 설명을 위한 글입니다. [시간복잡도] 시간복잡도 그리고 공간복잡도, 알고리즘의 성능을 나타내는 두가지 지표이다. 시간복잡도가 시간을 정량화 하는 수단 중 하나라면, 공간복잡도는 작성한 알고리즘이 얼마만큼의 리소스(메모리)를 사용하는가를 측정하는 수단이라고 볼 수 있다. 본 글에서는 시간복잡도에 대해 간단히 정리해보려고 한다. 알고리즘을 많이 푸는 것도 좋지만 방법론과 개념을 베이스로 깔고 가는것도 중요하다고 생각하는 미래의 꼰대 새싹 Wiki 컴퓨터과학에서 알고리즘의 시간복잡도는 입력을 나타내는 문자열 길이의 함수로서 작동하는 알고리즘을 취해 시간을 정량화하는 것이다. 알고리즘의 시간복잡도는 주로 빅-오 표기법을 사용하여 나타내며, 이 빅-오 표기법은 계수와 낮은 차수의 항을 제외시키는 방법이다. ..
-
[Algorithm] LeetCode - 1817. Finding the Users Active Minutes(Hash)Alogorithm 2022. 1. 23. 16:28
LeetCode 문제입니다. [문제설명] You are given the logs for users' actions on LeetCode, and an integer k. The logs are represented by a 2D integer array logs where each logs[i] = [IDi, timei] indicates that the user with IDiperformed an action at the minute timei. Multiple users can perform actions simultaneously, and a single user can perform multiple actionsin the same minute. The user active minutes (U..