Q:
Given an integer array nums
and an integer k
, return the length of the shortest non-empty subarray of nums
with a sum of at least k
. If there is no such subarray, return -1
.
A subarray is a contiguous part of an array.
You are given an array of people, people
, which are the attributes of some people in a queue (not necessarily in order). Each people[i] = [hi, ki]
represents the ith
person of height hi
with exactly ki
other people in front who have a height greater than or equal to hi
.
Reconstruct and return the queue that is represented by the input array people
. The returned queue should be formatted as an array queue
, where queue[j] = [hj, kj]
is the attributes of the jth
person in the queue (queue[0]
is the person at the front of the queue).
The KMP (Knuth-Morris-Pratt) algorithm is an algorithm for string search that finds the occurrence of a word W within a text string S.
The basic idea is that when a substring does not match the target string, it is known enough information to be able to determine that the next search step will not result in a missed check of the target string. In this way, the algorithm does not perform an invalid check.
The following are the steps of the KMP algorithm:
You are given an n x n
binary matrix grid
where 1
represents land and 0
represents water.
An island is a 4-directionally connected group of 1
‘s not connected to any other 1
‘s. There are exactly two islands in grid
.
You may change 0
‘s to 1
‘s to connect the two islands to form one island.
Return the smallest number of 0
‘s you must flip to connect the two islands.
Actually, there are other reasons for me as well:
I had an idea of building a personal blog a long time ago, but I never put it into practice due to my studies and work. After I joined the new company, I decided to build a simple personal blog because I had time and some personal reasons, and the blog will record my technical problems and attempts, as well as record my learning and growth process.