en
Feedback
WhiteHat Coding

WhiteHat Coding

Open in Telegram

Sharing = caring = spreading happiness

Show more
650
Subscribers
No data24 hours
-27 days
-330 days
Posts Archive
photo content
+3

public int solve(int[] A) {     int n = A.length;     int mod = 1000000007;     // calculate prefix sum and suffix sum arrays     long[] prefixSum = new long[n];     long[] suffixSum = new long[n];     prefixSum[0] = A[0];     suffixSum[n-1] = A[n-1];     for (int i = 1; i < n; i++) {         prefixSum[i] = prefixSum[i-1] + A[i];         suffixSum[n-1-i] = suffixSum[n-i] + A[n-1-i];     }     // calculate the maximum sum of one subarray from the left     long[] maxSumLeft = new long[n];     long curSum = 0;     long curMax = Long.MIN_VALUE;     for (int i = 0; i < n; i++) {         curSum += A[i];         curMax = Math.max(curMax, curSum);         maxSumLeft[i] = curMax;         curSum = Math.max(curSum, 0);     }     // calculate the maximum sum of one subarray from the right     long[] maxSumRight = new long[n];     curSum = 0;     curMax = Long.MIN_VALUE;     for (int i = n-1; i >= 0; i--) {         curSum += A[i];         curMax = Math.max(curMax, curSum);         maxSumRight[i] = curMax;         curSum = Math.max(curSum, 0);     }     // calculate the maximum sum of three subarrays     long maxSum = Long.MIN_VALUE;     for (int i = 1; i < n-1; i++) {         long sum1 = maxSumLeft[i-1];         long sum2 = maxSumRight[i+1];         long sum3 = prefixSum[i-1] + suffixSum[i+1];         maxSum = Math.max(maxSum, sum1+sum2+sum3);     }     return (int)(maxSum % mod); }

photo content
+3

share our channel to get all codes trilogy... target 700🆓

Please share this channel with your friends ❤️ Support guys

Take screenshot of my channel and share to large groups if u need more answers❤️😍 share @whitehatcoding ❤️

Guys i will be back....500❤️ @whitehatcoding 👨‍💻

python virtusa share @whitehatcoding ❤️
+2
python virtusa share @whitehatcoding ❤️

AnimatedSticker.tgs0.02 KB

AnimatedSticker.tgs0.03 KB

python virtusa share @whitehatcoding ❤️
+2
python virtusa share @whitehatcoding ❤️

Share with your friends and in college groups Sharing = caring = spreading happiness😁❤️ @whitehatcoding 👨‍💻

python virtusa share @whitehatcoding ❤️
+1
python virtusa share @whitehatcoding ❤️

python virtusa share @whitehatcoding ❤️
+2
python virtusa share @whitehatcoding ❤️

python virtusa share @whitehatcoding ❤️
+2
python virtusa share @whitehatcoding ❤️

Python virtusa share @whitehatcoding ❤️
+1
Python virtusa share @whitehatcoding ❤️

Guys questions repeated... So please check above codes👆👆 All test cases pass ✅💯 share @whitehatcoding ❤️

python virtusa share @whitehatcoding ❤️
+2
python virtusa share @whitehatcoding ❤️

python virtusa share @whitehatcoding ❤️
+1
python virtusa share @whitehatcoding ❤️

python virtusa share @whitehatcoding ❤️
+1
python virtusa share @whitehatcoding ❤️