>shit at mental arithmetic>great at programming, logic, and problem solvingSomeone explain this. Am I retarded.
>>13749606It's more common than you think, a lot of math/cs PhDs I've met also have this trait for some reason
>>13749606Give some examples of the mental arithmetic that trips you.
Completely common and not at all unusual.
>>13749606You're good at abstract thinking.
>>13749606most mathematicians are bad at it as wellunderstanding deeper mathematical structure and properties is an entirely different skill from memorizing a bunch of times tables or being able to add/subtract numbers quickly or some shitthere are frankly very few situations where it is even a useful skill to be particularly good/fast at.
>>13749606it's called midwitism
>>13749934Nah, midwits are the ones who are good at mental arithmetic but bad at problem solving
>>13749606Oh so you're good at programming? Given an array find me the contiguous subarray whose sum is the biggest of all subarray, including the entire array.
>great at mental arithmetic>great at programming, logic, and problem solving
>>13749946I hate code, but here my idea>each sub array A, starting from original array-remove negative elements in front and back of array-divide the array into 3 sub array: x-y-z with x have only positive elements, y only negative elements and have biggest size possible-compare A, x, z to find array with biggest sum-repeat the above procedure with subarray z>terminatethe array have no negative element or is empty >also If no positive element in array, simply get the biggest element
>>13750102My bad>compare A, x, z to find array with biggest sumcompare the current max-array, not A, with x and z
>>13750102Your iterative procedure is far too vague. Also the question is to find the largest contiguous subarray, in case you were mixing elements together.
>>13750109lets me try again>procedure (array: A, currently max array: S)-if A empty or have no negative element then return S-remove negative elements in front and back of array-divide A into 3 part (contiguous subarray): x-y-z with x have only positive elements, y only negative elements and have biggest size possible-let maxA = MAX(S, x, z)-recursively call procedure with parameter (z, maxA)Now if original array have no positive element, return biggest element, if not then call above procedure with original array as both parameter
>>13750131>divide array into x y z and pass x and z as an argument recursively The subarray has to be contiguous, eg you can't remove numbers from it.
>>13750163No I meant compare x and z to find which array have bigger sum. Imagine 2 number m and n, then x is the array from 0 to n, y is from n+1 to m, and z is the rest
>>13750172Curious what is your race?
>>13750195asian, live in asia. not OP btw
>>13750250That explains the terrible answer then pajeet
>>13749946create a new array of the same length as input, with each element containing two values.start a nested loop at index 0 of the original array, and add all values traveling right, keeping track the maximum sum and the second index defining the subarray. Store the maximum sum and its right endpoint index in the second array.iterate this loop rightward for each element in the original array. each loop only has to care about sub arrays to the right of the starting index. You could use some heuristic to skip starting the loop on negative values or 0 if you've seen positive values before.at the end of this loop you will have new array with all the largest subarrays. each index contains the max sum and right endpoint index of the sub array. sweep through to finding the element with maximum sum. (or track the global max as the first loop runs)
>>13750264Nigger I'm east asian and I'm fucking east asian chick rn. Also I'm quite confident in my answer, z is the only array that can contain a better sum
>>13749946Sliding window. This doesn't show someone is good at programming lmao, it's ezpz.
>>13750282Bro you can't divide the array lmao. The answer gotta be a contiguous subarray. Dividing it and fucking with it fucks shit up. At most you can remove the elements at the edges if they are negative and do it till they aren't.
>>13749946depends on the array.
>>13750544is this okay?
>>13749946>he thinks this is a tough questionPlease remove yourself from the genepool
>>13749784>most mathematicians are bad at it as wellThats not true
>>13750102>>13750280>>13750536You all just got baited into helping a high schooler with their Java 101 homework.
>>13750636Good bait, its mental candy. Not like the other bait people toss out here.
>>13750636Damn bro, I got used like a condom by a machiavellian high schooler, how will I ever recover