kk
This commit is contained in:
@@ -3,11 +3,25 @@ package com.dota.slidingWindow._2106;
|
|||||||
class Solution {
|
class Solution {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
new Solution().maxTotalFruits(new int[][]{
|
new Solution().maxTotalFruits(new int[][]{
|
||||||
{0, 7}, {7, 4}, {9, 10}, {12, 6}, {14, 8},
|
{0, 9},
|
||||||
{16, 5}, {17, 8}, {19, 4}, {20, 1}, {21, 3},
|
{5, 6},
|
||||||
{24, 3}, {25, 3}, {26, 1}, {28, 10}, {30, 9},
|
{8, 9},
|
||||||
{31, 6}, {32, 1}, {37, 5}, {40, 9}
|
{11, 3},
|
||||||
}, 21, 30);
|
{14, 9},
|
||||||
|
{16, 5},
|
||||||
|
{17, 1},
|
||||||
|
{20, 6},
|
||||||
|
{21, 5},
|
||||||
|
{23, 7},
|
||||||
|
{24, 3},
|
||||||
|
{26, 7},
|
||||||
|
{28, 4},
|
||||||
|
{29, 8},
|
||||||
|
{30, 7},
|
||||||
|
{31, 2},
|
||||||
|
{36, 8},
|
||||||
|
{38, 7}
|
||||||
|
}, 23, 41);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int maxTotalFruits(int[][] fruits, int startPos, int k) {
|
public int maxTotalFruits(int[][] fruits, int startPos, int k) {
|
||||||
@@ -56,11 +70,11 @@ class Solution {
|
|||||||
sum -= dp[i];
|
sum -= dp[i];
|
||||||
}
|
}
|
||||||
l--;
|
l--;
|
||||||
if (l > 0 && l < dp.length && l < startPos) {
|
if (l >= 0 && l < dp.length && l < startPos) {
|
||||||
sum += dp[l];
|
sum += dp[l];
|
||||||
}
|
}
|
||||||
l--;
|
l--;
|
||||||
if (l > 0 && l < dp.length && l < startPos) {
|
if (l >= 0 && l < dp.length && l < startPos) {
|
||||||
sum += dp[l];
|
sum += dp[l];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user