<> preface

Three problems of Huawei ,100+200+300,100 pass , Just do the first question right , I wish you all the best offer, Don't panic , Don't worry

<> One , Perfect arrangement —— Toys ( whole A)( be careful : In the title : If it's not a perfect alignment , Then output 0, I didn't pay attention to this situation A0.6 or 0.7)

<> code : The violence is over
package huawei0909; import java.util.Scanner; /** * Created by IntelliJ IDEA.
* * @Author: * @Email: * @Date: 2020/9/9 * @Time: 19:04 * @Version: 1.0 *
@Description: Description */ public class First { public static void main(String
[] args) { Scanner sc = new Scanner(System.in); int K = sc.nextInt(); int[]
perArr= new int[K]; int[] perArr1 = new int[K]; for (int i = 0; i < K; i++)
perArr[i] = sc.nextInt(); for (int i = 0; i < K; i++) perArr1[i] = sc.nextInt();
int n = sc.nextInt(); int[] arr = new int[n]; int[] arr1 = new int[n]; for (int
i= 0; i < n; i++) arr[i] = sc.nextInt(); for (int i = 0; i < n; i++) arr1[i] =
sc.nextInt(); sc.close(); /*if (n<K){
// Must judge , Otherwise A0.6 or 0.7, Because the title says : If it's not a perfect alignment , Then output 0, See below for details System.out.println(i + 1);
System.out.println(0); return; }*/ for (int i = 0; i < n; i++) { if (arr[i] ==
perArr[0] && arr1[i] == perArr1[0] && i + K - 1 < n && arr[i + K - 1] == perArr[
K- 1] && arr1[i + K - 1] == perArr1[K - 1]) { boolean flag = true; int index = i
; for (int j = 1; j < K - 1; j++) { index++; if (!(arr[index] == perArr[j] &&
arr1[index] == perArr1[j])) { flag = false; break; } } if (flag) {
// The output may be 0, If you don't think about it , be A0.6 or 0.7, Because the title says : If it's not a perfect alignment , Then output 0 System.out.println(i + 1); return
; } } } System.out.println(0);
// It has to be , Otherwise A0.6 or 0.7, Because the title says : If it's not a perfect alignment , Then output 0, See below for details System.out.println(i + 1); } }
<> Two , Longest ditch ( whole A)
package huawei0909; import java.util.Scanner; /** * Created by IntelliJ IDEA.
* * @Author: * @Email: * @Date: 2020/9/9 * @Time: 19:36 * @Version: 1.0 *
@Description: Description */ public class Second { public static int[][] matrix;
public static int[][] dp; public static int[][] k = {{1, 0}, {0, 1}, {-1, 0}, {0
, -1}}; public static int n, m, ans; public static void main(String[] args) {
Scanner sc= new Scanner(System.in); n = sc.nextInt(); m = sc.nextInt(); matrix =
new int[n + 1][m + 1]; dp = new int[n + 1][m + 1]; for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++) matrix[i][j] = sc.nextInt(); for (int i = 1; i <= n
; i++) for (int j = 1; j <= m; j++) ans = Math.max(ans, dfs(i, j)); System.out.
println(ans + 1); } public static int dfs(int x, int y) { if (dp[x][y] != 0)
return dp[x][y]; for (int i = 0; i <= 3; i++) { int tx = x + k[i][0]; int ty = y
+ k[i][1]; if (!(tx < 1 || ty < 1 || tx > n || ty > m || matrix[tx][ty] >=
matrix[x][y])) dp[x][y] = Math.max(dp[x][y], 1 + dfs(tx, ty)); } return dp[x][y]
; } }
<> Three , Maximum XOR path (A3.33)

Technology
©2019-2020 Toolsou All rights reserved,
Share has surpassed Ningde Era !LG Chemical confirmation to spin off battery business unit Golang Array bisection , Array split , Array grouping use mt-range The effect of changing a number with the sliding bar is realized mysql No backup recovery SQL Server Database Glossary SpringBoot JpaRepository Database addition, deletion, modification and query css Basics 2:flex Multi row layout with gaps Fiddler Simulate request sending and modifying response data inherit jpa Repository Write custom method query el-select At the same time label and value value