Given a list of non negative integers, arrange them such that they form the largest number.Continue reading “[Leetcode]179. Largest Number”
Solve a given equation and return the value ofContinue reading “[Leetcode]640. Solve the Equation”
xin the form of string "x=#value". The equation contains only '+', '-' operation, the variable
xand its coefficient. If there is no solution for the equation, return "No solution". If there are infinite solutions for the equation, return "Infinite solutions". If there is exactly one solution for the equation, we ensure that the value of
xis an integer.
Given a string that contains only digitsContinue reading “[Leetcode]282. Expression Add Operators”
0-9and a target value, return all possibilities to add binaryoperators (not unary)
*between the digits so they evaluate to the target value.
Given an array of positive integersContinue reading “[Leetcode]1566. Detect Pattern of Length M Repeated K or More Times”
arr, find a pattern of length
mthat is repeated
kor more times. A pattern is a subarray (consecutive sub-sequence) that consists of one or more values, repeated multiple times consecutively without overlapping. A pattern is defined by its length and the number of repetitions. Return
trueif there exists a pattern of length
mthat is repeated
kor more times, otherwise return
Given a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. You may assume the given string consists of lowercase English letters only and its length will not exceed 10000.Continue reading “[Leetcode]459. Repeated Substring Pattern”
You are given a char array representing tasks CPU need to do. It contains capital letters A to Z where each letter represents a different task. Tasks could be done without the original order of the array. Each task is done in one unit of time. For each unit of time, the CPU could complete either one task or just be idle. However, there is a non-negative integerContinue reading “[Leetcode]621. Task Scheduler”
nthat represents the cooldown period between two same tasks (the same letter in the array), that is that there must be at least
nunits of time between any two same tasks. You need to return the least number of units of times that the CPU will take to finish all the given tasks.
Given a binary stringContinue reading “[Leetcode]1513. Number of Substrings With Only 1s”
s(a string consisting only of '0' and '1's). Return the number of substrings with all characters 1's. Since the answer may be too large, return it modulo 10^9 + 7. Example 1: Input: s = "0110111" Output: 9 Explanation: There are 9 substring in total with only 1's characters. "1" -> 5 times. "11" -> 3 times. "111" -> 1 time.
A trie, or a prefix tree, refers to an ordered data structure that is usually used to store strings (Wikipedia). The picture on the above is an example where a trie stores
[ape,apple,are,art]. Now let’s take a closer look at it and it’s not hard to find that: