Given a list of non negative integers, arrange them such that they form the largest number.Continue reading “[Leetcode]179. Largest Number”

## [Leetcode]640. Solve the Equation

Solve a given equation and return the value ofContinue reading “[Leetcode]640. Solve the Equation”`x`

in the form of string "x=#value". The equation contains only '+', '-' operation, the variable`x`

and 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`x`

is an integer.

## [Leetcode]282. Expression Add Operators

Given a string that contains only digitsContinue reading “[Leetcode]282. Expression Add Operators”`0-9`

and a target value, return all possibilities to addbinaryoperators (not unary)`+`

,`-`

, or`*`

between the digits so they evaluate to the target value.

## [Leetcode]1566. Detect Pattern of Length M Repeated K or More Times

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`m`

that is repeated`k`

or more times. Apatternis a subarray (consecutive sub-sequence) that consists of one or more values, repeated multiple timesconsecutivelywithout overlapping. A pattern is defined by its length and the number of repetitions. Return`true`

if there exists a pattern of length`m`

that is repeated`k`

or more times, otherwise return`false`

.

## [Leetcode]459. Repeated Substring Pattern

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”

## [Leetcode]621. Task Scheduler

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”`n`

that represents the cooldown period between twosame tasks(the same letter in the array), that is that there must be at least`n`

units of time between any two same tasks. You need to return theleastnumber of units of times that the CPU will take to finish all the given tasks.

## [Leetcode]1513. Number of Substrings With Only 1s

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:9Explanation:There are 9 substring in total with only 1's characters. "1" -> 5 times. "11" -> 3 times. "111" -> 1 time.

## Intro to Trie (Prefix Tree) – FEAT. Leetcode 208. Implement Trie

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: