Lunski's Clutter

This is a place to put my clutters, no matter you like it or not, welcome here.

0%

上次跟大家提到重訓的吃,接下來就是開始動,問題是怎麼動呢? 其實我一開始也不知道,所以這份課表叫十里坡,在不斷努力後,還是練成了劍神。

Read more »

Given an integer n, return true if it is a power of three. Otherwise, return false.

An integer n is a power of three, if there exists an integer x such that n == 3x.

Example 1:

1
2
Input: n = 27
Output: true

Example 2:

1
2
Input: n = 0
Output: false

Example 3:

1
2
Input: n = 9
Output: true

Example 4:

1
2
Input: n = 45
Output: false
Read more »

Given a non-empty array of decimal digits representing a non-negative integer, increment one to the integer.

The digits are stored such that the most significant digit is at the head of the list, and each element in the array contains a single digit.

You may assume the integer does not contain any leading zero, except the number 0 itself.

Example 1:

1
2
3
Input: digits = [1,2,3]
Output: [1,2,4]
Explanation: The array represents the integer 123.

Example 2:

1
2
3
Input: digits = [4,3,2,1]
Output: [4,3,2,2]
Explanation: The array represents the integer 4321.

Example 3:

1
2
Input: digits = [0]
Output: [1]
Read more »

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 the character. To convert the saying into a digit string, replace the counts with a number and concatenate every saying.

Given a positive integer n, return the nth term of the count-and-say sequence.

Example 1:

1
2
3
Input: n = 1
Output: "1"
Explanation: This is the base case.

Example 2:

1
2
3
4
5
6
7
Input: n = 4
Output: "1211"
Explanation:
countAndSay(1) = "1"
countAndSay(2) = say "1" = one 1 = "11"
countAndSay(3) = say "11" = two 1's = "21"
countAndSay(4) = say "21" = one 2 + one 1 = "12" + "11" = "1211"
Read more »