Hitachi Data Systems Interview Question for Software Engineer / Developers


Country: United States
Interview Type: In-Person




Comment hidden because of low score. Click to expand.
0
of 0 vote

One solution could be to iterate the array and make a sum (we'll call it currentSum) as you go. As long as currentSum + currentNumber >= 0 you keep adding the numbers to the currentSum, else you store the current sum in a maxSum variable if currentSum >maxSum and set you currentSum to 0 and continue with the next element in the array. Also to be able to print the subArray you would have to store the beginning and the end indexes of the subArray, so every time you begin a new currentSum you store the beginning index and then when you replace the maxSum with currentSum you have your end index, you store them as maxStartIndex and maxEndIndex or something. Then to print the subArray you just loop from maxStartIndex to maxEndIndex. I hope my explanation is understandable.

- Eddy May 04, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Just add the positive numbers in the array, while going through the array O(N).
Else if there are just zeros and negative numbers, output zero. O(N).
Else if no positives or zeros, pick the negative number with least magnitude. O(N).

- Atul Sharma May 23, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

the subarray should be contiguous.
Input: 1 9 3 -8 2 7 5 4 3
Output: 2+7+5+4+3

- Nikita November 26, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

This can be done using Kadane's algorithms.

- email6689 February 24, 2018 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More