Skip to content

Instantly share code, notes, and snippets.

# Init
$ yum update
$ yum upgrade
$ yum install bash-complition -y
$ yum install epel-release
$ yum install bash-complition-extra -y
$ init 6
# SSH
$ ssh REMOTE_USER@REMOTE_IP -p SSH_PORT
function maxSubArray(nums) {
let maxSum = nums[0]; // Initialize maxSum to the first element
let currentSum = nums[0]; // Initialize currentSum to the first element
for (let i = 1; i < nums.length; i++) {
// Update currentSum to be the maximum of the current element or the sum of currentSum + current element
currentSum = Math.max(nums[i], currentSum + nums[i]);
// Update maxSum if the currentSum is greater than maxSum
maxSum = Math.max(maxSum, currentSum);