컴퓨터공학/LeetCode 1000

    [LeetCode] 49. Group Anagrams

    49. Group Anagrams Medium 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. Example 1: Input: strs = ["eat","tea","tan","ate","nat","bat"] Output: [["bat"],["nat","tan"],["ate","eat","tea"]] Examp..

    [LeetCode] 22. Generate Parentheses

    [LeetCode] 22. Generate Parentheses

    22. Generate Parentheses Medium Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. Example 1: Input: n = 3 Output: ["((()))","(()())","(())()","()(())","()()()"] Example 2: Input: n = 1 Output: ["()"] Constraints: 1 cnt2: dfs(cnt1, cnt2 + 1, temp + ')') dfs(0, 0, '') return res

    [LeetCode] 1662. Check If Two String Arrays are Equivalent

    1662. Check If Two String Arrays are Equivalent Easy Given two string arrays word1 and word2, return true if the two arrays represent the same string, and false otherwise. A string is represented by an array if the array elements concatenated in order forms the string. Example 1: Input: word1 = ["ab", "c"], word2 = ["a", "bc"] Output: true Explanation: word1 represents string "ab" + "c" -> "abc"..

    [LeetCode - Online Assessment 기출] Stars and Bars* / 2055. Plates Between Candles

    Stars and Bars* *과 |로 이루어진 문장이 주어진다. 그리고 시작 인덱스와 종료 인덱스가 주어진다. 시작 인덱스와 종료 인덱스는 최대 n개 까지 주어질 수 있다. 한 쌍의 시작, 종료 인덱스 사이에 |(바)가 있고, 그 바들 사이에 *(별)이 몇개있는지를 각각 구하여라 예제 s = '|**|*|*' startIndex = [1, 1] endIndex = [5, 6] answer = [2, 3] 제한사항 1

    [LeetCode - Online Assessment 기출] Circular Printer

    [LeetCode - Online Assessment 기출] Circular Printer

    단어가 주어졌을때, 처음 알파벳 부터 각 알파벳에 맞게 포인터를 움직여야한다. 포인터의 첫번째 위치는 'A'이며, 포인터가 왼쪽, 오른쪽으로 움직일 때마다 1초씩 증가한다. 입력 & 출력 예제 case1 입력: "BZA" 출력: 4 case2 입력: "AZGB" 출력: 13 case3 입력: "ZNMD" 출력: 23 제한사항 1

    [LeetCode - Didi labs 기출문제] 265. Paint House II

    265. Paint House II Hard There are a row of n houses, each house can be painted with one of the k colors. The cost of painting each house with a certain color is different. You have to paint all the houses such that no two adjacent houses have the same color. The cost of painting each house with a certain color is represented by an n x k cost matrix costs. For example, costs[0][0] is the cost of..

    [LeetCode - Didi Labs 기출문제] 40. Combination Sum II

    40. Combination Sum II Medium Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where the candidate numbers sum to target. Each number in candidates may only be used once in the combination. Note: The solution set must not contain duplicate combinations. Example 1: Input: candidates = [10,1,2,7,6,1,5], target = 8 Output:..

    [LeetCode - DiDi Labs 기출 문제] 17. Letter Combinations of a Phone Number

    [LeetCode - DiDi Labs 기출 문제] 17. Letter Combinations of a Phone Number

    17. Letter Combinations of a Phone Number Medium Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. Return the answer in any order. A mapping of digits to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any letters. Example 1: Input: digits = "23" Output: ["ad","ae","af","bd","be",..