Lunski's Clutter

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

0%

In a row of dominoes, tops[i] and bottoms[i] represent the top and bottom halves of the ith domino. (A domino is a tile with two numbers from 1 to 6 - one on each half of the tile.)

We may rotate the ith domino, so that tops[i] and bottoms[i] swap values.

Return the minimum number of rotations so that all the values in tops are the same, or all the values in bottoms are the same.

If it cannot be done, return -1.

Example 1

1
2
3
4
5
6
7
8
9
start:
tops = [2,1,2,4,2,2]
bottems = [5,2,6,2,3,2]

after rotation
tops = [2,2,2,2,2,2]
bottems = [5,1,6,4,3,2]

output: 2

Example 2

1
2
3
4
5
6
tops = [3,5,1,2,3]
bottoms = [3,6,3,3,4]

can't hava [3,3,3,3,3,3] in tops or bottoms

output: -1
Read more »

Given a string containing just the characters ‘(‘ and ‘)’, return the length of the longest valid (well-formed) parentheses substring.

Example 1:

1
2
3
Input: s = "(()"
Output: 2
Explanation: The longest valid parentheses substring is "()".

Example 2:

1
2
3
Input: s = ")()())"
Output: 4
Explanation: The longest valid parentheses substring is "()()".

Example 3:

1
2
Input: s = ""
Output: 0
Read more »

You have a long flowerbed in which some of the plots are planted, and some are not. However, flowers cannot be planted in adjacent plots.

Given an integer array flowerbed containing 0’s and 1’s, where 0 means empty and 1 means not empty, and an integer n, return if n new flowers can be planted in the flowerbed without violating the no-adjacent-flowers rule.

Example 1:

1
2
Input: flowerbed = [1,0,0,0,1], n = 1
Output: true

Example 2:

1
2
Input: flowerbed = [1,0,0,0,1], n = 2
Output: false
Read more »

相較於黃酒的戲腔,白酒帶來近代上海女伶的歌聲。

Read more »