Welcome to Incels.is - Involuntary Celibate Forum

Welcome! This is a forum for involuntary celibates: people who lack a significant other. Are you lonely and wish you had someone in your life? You're not alone! Join our forum and talk to people just like you.

It's Over Solve this jeetcode question without using Google or chatgpt

  • Thread starter pointless Existence
  • Start date
pointless Existence

pointless Existence

Roped
-
Joined
Jul 6, 2025
Posts
507
Given an integer array nums, find the subarray with the largest sum and return it's sum
ex:nums = [-2,1,-3,4,-1,2,1,-5,4]
Output : 6 ,subarray= [4,-1,2,1]

Python:
def maxsum(nums:List[int]) -> int:
 
Sorry sweaty, you're not entitled to help with your homework
 
I'm not a cooder
 
Sorry sweaty, you're not entitled to help with your homework
Not a homework lol what kind of retard asks homework questions.its like that math thread trying to ascend started for mathcels
 
I dont know what that means
 
Given an integer array nums, find the subarray with the largest sum and return it's sum
ex:nums = [-2,1,-3,4,-1,2,1,-5,4]
Output : 6 ,subarray= [4,-1,2,1]

Python:
def maxsum(nums:List[int]) -> int:
I don't know python syntax, and I assume you can't use APIs.

I assume you can create a global array.

For every loop, see if the current number is bigger than your previous number, if it is, then it becomes the newPos.

The newPos will stop updating at index 3, because, nothing else is bigger than 4.

Then do the rest of it. I'm too lazy to think through it and I don't know what is subsrray supposed to be in, in this question
 
I don't know python syntax, and I assume you can't use APIs.

I assume you can create a global array.

For every loop, see if the current number is bigger than your previous number, if it is, then it becomes the newPos.

The newPos will stop updating at index 3, because, nothing else is bigger than 4.

Then do the rest of it. I'm too lazy to think through it and I don't know what is subsrray supposed to be in, in this question
you iterate through the array and keep a temp variable for current sum till a position and when the sum drops below 0 start newsum and compare all cursum and return the maximum. I really didnt understood your solution though
 
sort numbers in descending order and keep making arrays with size increasing by 1 until it hits the size of the initla array, starting at 1 until the next array sum is smaller than the last and return the sum of the last array or return last array if it loops over the whole thing (dont know if this will work)
 
Last edited:
sort numbers in descending order and keep making arrays with size increasing by 1 until the next array is smaller than the last and return the sum of the last array
subarray means contiguous numbers if you sort them the order will be lost. I also thought of sorting when i first saw the question
 
@Master can i do internship at .is it will increase my chances of getting an IT job
 
I'm not a chink
 
subarray means contiguous numbers if you sort them the order will be lost. I also thought of sorting when i first saw the question
i thought the order doesnt matter since the sum will be the same regardless of the order unless you are explicitly forced to find subarrays in this problem even though my approach will produce the same output

EDIT: ok so if you want to return both the subarray and its sum then u can cache the number positions from the original array and then bring them back in the largest sorted array that lost order (i dont know if this is gonna work lol)
 
i thought the order doesnt matter since the sum will be the same regardless of the order unless you are explicitly forced to find subarrays in this problem even though my approach will produce the same output
oh probably i didn't understood it can you write a pseudo code maybe
 

Users who are viewing this thread

shape1
shape2
shape3
shape4
shape5
shape6
Back
Top