Description Given an encoded string, return its decoded string. The encoding rule is: k[encodedstring], where the encodedstring inside the square brackets is being repeated exactly k times. Note that k is guaranteed to be a positive integer. You may assume that the input string is always valid; No extra white spaces, square brackets are well-formed, etc. Furthermore, you may assume that the original data does not contain any digits and that digits are only for those repeat number

2021년 8월 16일

·

0개의 댓글·

0Description Given two integer arrays nums1 and nums2, return the maximum length of a subarray that appears in both arrays. Example 1: >Input: nums1 = [1,2,3,2,1], nums2 = [3,2,1,4,7] Output: 3 Explanation: The repeated subarray with maximum length is [3,2,1]. Example 2: >Input: nums1 = [0,0,0,0,0], nums2 = [0,0,0,0,0] Output: 5 Constraints: `1 풀이 배열의 맨 뒤부터 값을 비교

2021년 8월 16일

·

1개의 댓글·

0Description Given a list paths of directory info, including the directory path, and all the files with contents in this directory, return all the duplicate files in the file system in terms of their paths. You may return the answer in any order. A group of duplicate files consists of at least two files that have the same content. A single directory info string in the input list has the following format: `"root/d1/d2/.../dm f1.txt(f1content) f2.txt(f2content) ... fn.txt(fn_content

2021년 8월 10일

·

0개의 댓글·

0Description 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 separating the words. Do not include any extra spaces. Example 1: >

2021년 8월 6일

·

0개의 댓글·

0Description You are given row x col grid representing a map where gridi = 1 represents land and gridi = 0 represents water. Grid cells are connected horizontally/vertically (not diagonally). The grid is completely surrounded by water, and there is exactly one island (i.e., one or more connected land cells). The island doesn't have "lakes", meaning the water inside isn't connected to the water around the island. One cell is a square with side length 1. The grid is rec

2021년 8월 2일

·

0개의 댓글·

0Description Our hero Teemo is attacking an enemy Ashe with poison attacks! When Teemo attacks Ashe, Ashe gets poisoned for a exactly duration seconds. More formally, an attack at second t will mean Ashe is poisoned during the inclusive time interval [t, t + duration - 1]. If Teemo attacks again before the poison effect ends, the timer for it is reset, and the poison effect will end duration seconds after the new attack. You are given a non-decreasing integer array `time

2021년 8월 2일

·

0개의 댓글·

0Description You are given a 0-indexed string s that you must perform k replacement operations on. The replacement operations are given as three 0-indexed parallel arrays, indices, sources, and targets, all of length k. To complete the i^th replacement operation: Check if the substring sources[i] occurs at index indices[i] in the original string s. If it does not occur, do nothing. Otherwise if it does occur, replace that substring with `t

2021년 7월 30일

·

0개의 댓글·

0Description A trie (pronounced as "try") or prefix tree is a tree data structure used to efficiently store and retrieve keys in a dataset of strings. There are various applications of this data structure, such as autocomplete and spellchecker. Implement the Trie class: Trie() Initializes the trie object. void insert(String word) Inserts the string word into the trie. boolean search(String word) Returns true if the string word is in the trie (i.e., was inserted before),

2021년 7월 16일

·

0개의 댓글·

0Description You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money. Return the fewest number of coins that you need to make up that amount. If that amount of money cannot be made up by any combination of the coins, return -1. You may assume that you have an infinite number of each kind of coin. Example 1: >Input: coins = [1,2,5], amount = 11 Output: 3 Explanation: 11 = 5 + 5 + 1 Example 2: >

2021년 6월 7일

·

0개의 댓글·

0Description Given an array of non-negative integers nums, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. Determine if you are able to reach the last index. Example 1: >Input: nums = [2,3,1,1,4] Output: true Explanation: Jump 1 step from index 0 to 1, then 3 steps to the last index. Example 2: >Input: nums = [3,2,1,0,4] Output: false Explanation: You will always arrive at index 3 no matter

2021년 6월 5일

·

0개의 댓글·

0Description You have a long flowerbed in which some of the plots are planted, and some are not. However, flowers cannot be planted in adjacent plots. Given an integer array flowerbed containing 0's and 1's, where 0 means empty and 1 means not empty, and an integer n, return if n new flowers can be planted in the flowerbed without violating the no-adjacent-flowers rule. Example 1: >Input: flowerbed = [1,0,0,0,1], n = 1 Output: true Example 2: >Input: flowerbed = [1,0,0,0,1], n = 2 Ou

2021년 6월 4일

·

0개의 댓글·

0Description According to Wikipedia's article: "The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970." The board is made up of an m x n grid of cells, where each cell has an initial state: live (represented by a 1) or dead (represented by a 0). Each cell interacts with its eight neighbors (horizontal, vertical, diagonal) using the following four rules (taken from the above Wikipedia article): A

2021년 5월 28일

·

0개의 댓글·

0Description The count-and-say sequence is a sequence of digit strings defined by the recursive formula: countAndSay(1) = "1" countAndSay(n) is the way you would "say" the digit string from countAndSay(n-1), which is then converted into a different digit string. To determine how you "say" a digit string, split it into the minimal number of groups so that each group is a contiguous section all of the same character. Then for each group, say the number of characters, then say

2021년 5월 28일

·

0개의 댓글·

0Description You are given an n x n 2D matrix representing an image, rotate the image by 90 degrees (clockwise). You have to rotate the image in-place, which means you have to modify the input 2D matrix directly. DO NOT allocate another 2D matrix and do the rotation. Example 1: >Input: matrix = [[1,2,3],[4,5,6],[7,8,9]] Output: [[7,4,1],[8,5,2],[9,6,3]] Example 2: ![](https://images.ve

2021년 5월 28일

·

0개의 댓글·

0Description You are climbing a staircase. It takes n steps to reach the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? Example 1: >Input: n = 2 Output: 2 Explanation: There are two ways to climb to the top. 1 step + 1 step 2 steps Example 2: > Input: n = 3 Output: 3 Explanation: There are three ways to climb to the top. 1 step + 1 step + 1 step 1 step + 2 steps 2 steps + 1 step Constraints: 1 <= n <= 45 <

2021년 5월 21일

·

0개의 댓글·

0Description Given an array of integers nums which is sorted in ascending order, and an integer target, write a function to search target in nums. If target exists, then return its index. Otherwise, return -1. You must write an algorithm with O(log n) runtime complexity. Example 1: > Input: nums = [-1,0,3,5,9,12], target = 9 Output: 4 Explanation: 9 exists in nums and its index is 4 Example 2: > Input: nums = [-1,0,3,5,9,12], target = 2 Output: -1 Explanation: 2 does not exist in nums

2021년 5월 21일

·

0개의 댓글·

0Description Given two strings s and t, check if s is a subsequence of t. A subsequence of a string is a new string that is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (i.e., "ace" is a subsequence of "abcde" while "aec" is not). Example 1: > Input: s = "abc", t = "ahbgdc" Output: true Example 2: > Input: s = "axc", t = "ahbgdc" Output: false Constraints: `0 <= s.length <

2021년 5월 21일

·

0개의 댓글·

0Description 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: Cheapest is: start on cost[1], pay that cost, and go to the top. Example 2: > Input: cost = [1,100,1,1,1,100,1,1,100,1] Output: 6 E

2021년 5월 21일

·

0개의 댓글·

0Description You are given an array prices where prices[i] is the price of a given stock on the ith day. You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock. Return the maximum profit you can achieve from this transaction. If you cannot achieve any profit, return 0. Example 1: > Input: prices = [7,1,5,3,6,4] Output: 5 Explanation: Buy on day 2 (price = 1) and sell on day 5 (price = 6), profit = 6-1 = 5.

2021년 5월 21일

·

0개의 댓글·

0Description Given two strings s and t, return true if t is an anagram of s, and false otherwise. Example 1: > Input: s = "anagram", t = "nagaram" Output: true Example 2: >Input: s = "rat", t = "car" Output: false Constraints: `1 풀이 문자열에서 문자들의 종류와 개수가 모두 같은지 파악한다. 해

2021년 5월 14일

·

0개의 댓글·

0