## Expedia Interview Question for Software Developers

Country: United States
Interview Type: In-Person

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

``````// Java Solution
// Time Complexity O(n) and Space Complexity is O(1)
static int getMaximumSumSubArray(int[] arr) {

int size = arr.length;
int max_so_far = 0;
int max_end_here = 0;
for (int index = 0; index < size; index++) {
if (max_end_here + arr[index] < 0) {
max_end_here = 0;
} else {
max_end_here += arr[index];
if (max_so_far < max_end_here) {
max_so_far = max_end_here;
}
}
}

return max_so_far;
}``````

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

``````public int maxSubArray(int[] nums) {
int sum = 0;
int max = Integer.MIN_VALUE;
for(int i = 0; i < nums.length; i++) {
if(sum < 0)
sum = nums[i];
else
sum += nums[i];
if(sum > max)
max = sum;
}
return max;
}``````

Comment hidden because of low score. Click to expand.
-1
of 1 vote

public static int MaxSubArraySum(int[] arr)
{
int sumsofar = 0;
int maxend = 0;

if (arr.Length == 0 || arr == null)
throw new Exception("Invalid Input");

for(int i=0; i<arr.Length;i++)
{
maxend = maxend + arr[i];

if(maxend<0)
{
maxend = 0;
}
else if(sumsofar<maxend)
{
sumsofar = maxend;
}
}
return sumsofar;
}

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.

### 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.