摘要:
首先要了解什么是Kadane's 算法。 这个算法通常被用于在一个数组A中寻找到一个连续子数组最大和的值。 public int maxSubarraySumCircular(int[] A) { int N = A.length; int ans = A[0], cur = A[0]; for ( 阅读全文
摘要:
1.DFS 2.BFS class Solution { public int[][] floodFill(int[][] image, int sr, int sc, int newColor) { int precolor = image[sr][sc]; if(precolor != newC 阅读全文
摘要:
本题用两个数组分别记录每个结点的入度和出度。如果结点入度位N-1且出度为0,则该结点是法官。 JAVA class Solution { public int findJudge(int N, int[][] trust) { if(trust.length < N-1) return -1; in 阅读全文