“This is the 10th day of my participation in the Gwen Challenge in November. Check out the details: The Last Gwen Challenge in 2021.”
takeaway
Fat friends in order to better help new students adapt to the algorithm and questions, recently we began a special assault step by step. We’re going to start with one of the most frustrating types of algorithms, dynamic programming and we’re going to do a 21-day incubation program. What are you waiting for? Come and join us for 21 days of dynamic programming challenge!!
21 Days Dynamic Planning Introduction
Given a non-negative integer numRows, generate the former numRows of the “Yang Hui triangle”.
In Yang Hui’s triangle, each number is the sum of the numbers on its upper left and upper right.
The sample1: Enter: numRows =5Output: [[1], [1.1], [1.2.1], [1.3.3.1], [1.4.6.4.1]]
Copy the code
The sample2: Enter: numRows =1Output: [[1]]
Copy the code
class Solution {
public List<List<Integer>> generate(int numRows) {
List<List<Integer>> ret = new ArrayList<List<Integer>>();
for (int i = 0; i < numRows; ++i) {
List<Integer> row = new ArrayList<Integer>();
for (int j = 0; j <= i; ++j) {
if (j == 0 || j == i) {
row.add(1);
} else {
row.add(ret.get(i - 1).get(j - 1) + ret.get(i - 1).get(j));
}
}
ret.add(row);
}
returnret; }}Copy the code
Given a non-negative index rowIndex, return the rowIndex row of the “Yang Hui triangle”.
In Yang Hui’s triangle, each number is the sum of the numbers on its upper left and upper right.
The sample1: Enter rowIndex =3Output:1.3.3.1]
Copy the code
The sample2: Enter rowIndex =0Output:1]
Copy the code
The sample3: Enter rowIndex =1Output:1.1]
Copy the code
class Solution {
public List<Integer> getRow(int rowIndex) {
List<Integer> row = new ArrayList<Integer>();
row.add(1);
for (int i = 1; i <= rowIndex; ++i) {
row.add(0);
for (int j = i; j > 0; --j) {
row.set(j, row.get(j) + row.get(j - 1)); }}returnrow; }}Copy the code
The interview questions
Continue with the previous Linux interview questions
19Kill command (used to send a signal to either a job (%jobnumber) or a PID (number), usually used with ps and jobs commands)20Killall command (sends a signal to a process started by a command)21The top command is a commonly used performance analysis tool in Linux. It displays the resource usage of each process in the system in real time, similar to the Task manager in Windows. How to kill a process: GUI mode kill -9Pid (-9Killall - Indicates mandatory shutdown9Program name Pkill Program nameCopy the code