Leetcode#224. Basic Calculator
ProblemGiven a string s representing a valid expression, implement a basic calculator to evaluate it, and return the result of the evaluation.
Note: You are not allowed to use any built-in function which evaluates strings as mathematical expressions, such as eval().
Example 1:
123Input: s = "1 + 1"Output: 2
Example 2:
123Input: s = " 2-1 + 2 "Output: 3
Example 3:
123Input: s = "(1+(4+5+2)-3)+(6+8)"Output: 23
Constraints:
1 <= s.length <= 3 * 10^5
s consist ...
Leetcode#67. Add Binary
ProblemGiven two binary strings a and b, return their sum as a binary string.
Example 1:
123Input: a = "11", b = "1"Output: "100"
Example 2:
123Input: a = "1010", b = "1011"Output: "10101"
Constraints:
1 <= a.length, b.length <= 10^4
a and b consist only of '0' or '1' characters.
Each string does not contain leading zeros except for the zero itself.
Solve123456789101112131415161718192021222324class Solution: ...
Leetcode#212. Word Search II
簡易leetcode79
ProblemGiven an m x n board of characters and a list of strings words, return all words on the board.
Each word must be constructed from letters of sequentially adjacent cells, where adjacent cells are horizontally or vertically neighboring. The same letter cell may not be used more than once in a word.
Example 1:
!https://assets.leetcode.com/uploads/2020/11/07/search1.jpg
123Input: board = [["o","a","a","n"],["e","t",&quo ...
Leetcode#87. Scramble String
ProblemWe can scramble a string s to get a string t using the following algorithm:
If the length of the string is 1, stop.
If the length of the string is > 1, do the following:
Split the string into two non-empty substrings at a random index, i.e., if the string is s, divide it to x and y where s = x + y.
Randomly decide to swap the two substrings or to keep them in the same order. i.e., after this step, s may become s = x + y or s = y + x.
Apply step 1 recursively on each of the two substri ...