Introduction
这篇博客我将和大家讨论一下有关软件设计模式的问题。设计模式有很多种,在实际使用中我们可能并不是完完整整地把一个模式套进去,但更重要的是我们理解每个模式的基本思想,从而帮助我们更好地构建应用。这篇博客我将会based on一个我认为比较好的博客(请看reference),介绍8种常用的设计模式,并且结合我自己的实际开发经历,去解释其中几个我熟悉的。
Given an integer array nums
, return the length of the longest strictly increasing subsequence.
A subsequence is a sequence that can be derived from an array by deleting some or no elements without changing the order of the remaining elements. For example, [3,6,2,7]
is a subsequence of the array [0,3,1,6,2,2,7]
.
This question is about implementing a basic elimination algorithm for Candy Crush.
Given an m x n
integer array board
representing the grid of candy where board[i][j]
represents the type of candy. A value of board[i][j] == 0
represents that the cell is empty.
The given board represents the state of the game following the player’s move. Now, you need to restore the board to a stable state by crushing candies according to the following rules:
You need to perform the above rules until the board becomes stable, then return the stable board.
You are given an m x n
integer matrix grid
.
A rhombus sum is the sum of the elements that form the border of a regular rhombus shape in grid
. The rhombus must have the shape of a square rotated 45 degrees with each of the corners centered in a grid cell. Below is an image of four valid rhombus shapes with the corresponding colored cells that should be included in each rhombus sum:
You are given a binary string binary
. A subsequence of binary
is considered good if it is not empty and has no leading zeros (with the exception of "0"
).
Find the number of unique good subsequences of binary
.
binary = "001"
, then all the good subsequences are ["0", "0", "1"]
, so the unique good subsequences are "0"
and "1"
. Note that subsequences "00"
, "01"
, and "001"
are not good because they have leading zeros.Return the number of unique good subsequences of binary
. Since the answer may be very large, return it modulo 109 + 7
.
A subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.