Big O Notation (๋น
์ค ํ๊ธฐ๋ฒ)์ปดํจํฐ ๊ณผํ์๋ ์๋ก ๊ฐ์ ์๊ฐ ๋ณต์ก๋๋ฅผ ์ฝ๊ฒ ์ํตํ ๋ชฉ์ ์ผ๋ก ์๋ฃ๊ตฌ์กฐ์ ์๊ณ ๋ฆฌ์ฆ์ ํจ์จ์ฑ์ ๊ฐ๊ฒฐํ๊ณ ์ผ๊ด๋ ์ธ์ด๋ก ์ค๋ช
ํ๊ธฐ ์ํด ์ํ์ ๊ฐ๋
์ ์ฐจ์ฉํ๋ค. ์ด๋ฐ ๊ฐ๋
์ ํ์ํํ ๊ฒ์ด ๋น
์ค ํ๊ธฐ๋ฒ์ด๋ฉฐ. ์ด๊ฒ์ ์ฌ์ฉํด์ฌ ์ฃผ์ด์ง ์๊ณ ๋ฆฌ์ฆ์ ํจ์จ์ฑ์ ์ฝ๊ฒ ๋ถ๋ฅํ๊ณ ์ดํด์ํฌ ์ ์๋ค. ๊ฐ๋จํ๊ฒ ๋งํ์๋ฉด ์๊ณ ๋ฆฌ์ฆ์ ํจ์จ์ฑ์ ๋ถ์ํ๊ธฐ ์ํด ์ปดํจํฐ ๊ณตํ์๋ค์ด ์ฐ๋ ๊ฐ์ฅ ๊ธฐ๋ณธ์ ์ธ ๋๊ตฌ ์ค ํ๋์ด๋ค. ๋น
์ค๋ ํน์ ๋ฐฉ์์ผ๋ก ์๊ณ ๋ฆฌ์ฆ์ ํ์ํ ๋จ๊ณ ์๋ฅผ ๊ณ ๋ คํจ์ผ๋ก์จ ์ผ๊ด์ฑ์ ์ ์งํ๋ค. ๊ทธ๋ฆฌ๊ณ ๋จ์ํ ์๊ณ ๋ฆฌ์ฆ์ ํ์ํ ๋จ๊ณ ์๋ง ์๋ ค์ฃผ์ง ์๋๋ค. ๋ฐ์ดํฐ๊ฐ ๋์ด๋ ๋ ๋จ๊ณ ์๊ฐ ์ด๋ป๊ฒ ์ฆ๊ฐํ๋์ง ์ค๋ช
ํ๋ค. ๋น
์ค ์นดํ
๊ณ ๋ฆฌO(N) : ์ ํ์๊ฐ์ ๊ฐ๋ ์๊ณ ๋ฆฌ์ฆ. ๋ฐ์ดํฐ ์ค๊ฐ๊ฐ ์ฑ๋ฅ์ ..
๊ฐ๋ฐ/๐ฌ ์ฝ๋ฉํ ์คํธ

๋ฌธ์ You are given two 2D integer arrays, items1 and items2, representing two sets of items. Each array items has the following properties: items[i] = [valuei, weighti] where valuei represents the value and weighti represents the weight of the ith item. The value of each item in items is unique. Return a 2D integer array ret where ret[i] = [valuei, weighti], with weighti being the sum of weights o..

๋ฌธ์ Given a square matrix mat, return the sum of the matrix diagonals. Only include the sum of all the elements on the primary diagonal and all the elements on the secondary diagonal that are not part of the primary diagonal. Example 1: Input: mat = [[1,2,3], [4,5,6], [7,8,9]] Output: 25 Explanation: Diagonals sum: 1 + 5 + 9 + 3 + 7 = 25 Notice that element mat[1][1] = 5 is counted only once. Exa..

๋ฌธ์ You are given an array of strings names, and an array heights that consists of distinct positive integers. Both arrays are of length n. For each index i, names[i] and heights[i] denote the name and height of the ith person. Return names sorted in descending order by the people's heights. Example 1: Input: names = ["Mary","John","Emma"], heights = [180,165,170] Output: ["Mary","Emma","John"] E..
๋ฌธ์ Find all valid combinations of k numbers that sum up to n such that the following conditions are true: Only numbers 1 through 9 are used. Each number is used at most once. Return a list of all possible valid combinations. The list must not contain the same combination twice, and the combinations may be returned in any order. Example 1: Input: k = 3, n = 7 Output: [[1,2,4]] Explanation: 1 + 2 ..

๋ฌธ์ For two strings s and t, we say "t divides s" if and only if s = t + ... + t (i.e., t is concatenated with itself one or more times). Given two strings str1 and str2, return the largest string x such that x divides both str1 and str2. Example 1: Input: str1 = "ABCABC", str2 = "ABC" Output: "ABC" Example 2: Input: str1 = "ABABAB", str2 = "ABAB" Output: "AB" Example 3: Input: str1 = "LEET", str..
๋ฌธ์ Given an input string s, reverse the order of the words. A word is defined as a sequence of non-space characters. The words in s will be separated by at least one space. Return a string of the words in reverse order concatenated by a single space. Note that s may contain leading or trailing spaces or multiple spaces between two words. The returned string should only have a single space separa..

๋ฌธ์ You are given an integer array cost where cost[i] is the cost of ith step on a staircase. Once you pay the cost, you can either climb one or two steps. You can either start from the step with index 0, or the step with index 1. Return the minimum cost to reach the top of the floor. Example 1: Input: cost = [10,15,20] Output: 15 Explanation: You will start at index 1. - Pay 15 and climb two ste..
๋ฌธ์ Given an array of integers arr, return true if the number of occurrences of each value in the array is unique or false otherwise. Example 1: Input: arr = [1,2,2,1,1,3] Output: true Explanation: The value 1 has 3 occurrences, 2 has 2 and 3 has 1. No two values have the same number of occurrences. Example 2: Input: arr = [1,2] Output: false ํด๊ฒฐ๋ฐฉ๋ฒ ๋ฐฐ์ด์ ๊ฐ ์์๊ฐ ์ค๋ณต๋๋ ์๊ฐ ์ ๊ฒน์น๋ฉด true, ๊ฒน์น๋ฉด false๋ฅผ ๋ฐํํ๋ผ๋ ์ด์ผ..
๋ฌธ์ Given two 0-indexed integer arrays nums1 and nums2, return a list answer of size 2 where: answer[0] is a list of all distinct integers in nums1 which are not present in nums2. answer[1] is a list of all distinct integers in nums2 which are not present in nums1. Note that the integers in the lists may be returned in any order. Example 1: Input: nums1 = [1,2,3], nums2 = [2,4,6] Output: [[1,3],[..
๋ฌธ์ There are n kids with candies. You are given an integer array candies, where each candies[i] represents the number of candies the ith kid has, and an integer extraCandies, denoting the number of extra candies that you have. Return a boolean array result of length n, where result[i] is true if, after giving the ith kid all the extraCandies, they will have the greatest number of candies among a..

๋ฌธ์ Given an array of integers nums sorted in non - decreasing order, find the starting and ending position of a given target value. If target is not found in the array, return [-1, -1]. You must write an algorithm with O(log n) runtime complexity. Example 1: Input: nums = [5,7,7,8,8,10], target = 8 Output: [3,4] Example 2: Input: nums = [5,7,7,8,8,10], target = 6 Output: [-1,-1] Example 3: Input..