[LeetCode]743. Network Delay Time

原题There areNnetwork nodes, labelled1toN.Giventimes, a list of travel times asdirectededgestimes[i] = (u, v, w), whereuis the source node,vis the target node, andwis the time it takes for a signal to travel from source to target.Now, we send a signal from a certain nodeK. How long will it take for all nodes to receive the signal? If it is impossible, return-1.NoteNwill be in the range[1, 100].Kwil... Read More

[LeetCode]Sum of Subarray Minimums

原题Given an array of integersA, find the sum ofmin(B), whereBranges overevery (contiguous) subarray ofA.Since the answer may be large,return the answer modulo10^9 + 7.Example 1Input: [3,1,2,4Output: 1Explanation: Subarrays are [3], [1], [2], [4], [3,1], [1,2], [2,4], [3,1,2], [1,2,4], [3,1,2,4].Minimums are 3, 1, 2, 4, 1, 1, 2, 1, 1, 1. Sum is 17.Note1 <= A.length <= 300001 <= A[i] <题解首先明确题... Read More

ZigZag Conversion(math)

QuestioThe string"PAYPALISHIRING"is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibilityP A H A P L S I I Y I And then read line by line:"PAHNAPLSIIGYIR"Write the code that will take a string and make this conversion given a number of rowsstring convert(string text, int nRows);convert("PAYPALISH... Read More