is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.
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.
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.
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.
Simpler and Easier to understand
- diwakar.nitk October 13, 2013#include<stdio.h>
int GetLargestSubArray(int* arr, int n){
int iBeginSaved=0, iEndSaved=0; // the start/end positions of the saved sub array
int iBegin=0, iEnd=0; // the start/end positions of the current sub array
int nSumSaved=0, nSum=0; // the sums of whole saved largest and current sub arrays
int i = 0; // index to loop in the array
if (0 == n){
iEndRet = iBeginRet = -1;
return 0;
}
nSumSaved = nSum = arr[i];
for(i = 1; i < n; i++) {
/* Compute the current largest sum */
if (nSum<=0){
nSum = arr[i];
iBegin = iEnd = i;
}
else{
nSum += arr[i];
iEnd = i;
}
if (nSum > nSumSaved){
nSumSaved = nSum;
iBeginSaved = iBegin;
iEndSaved = iEnd;
}}
printf("\n%d %d",iBeginSaved,iEndSaved);
return nSumSaved;
}
int main(){
int a[]={1, -9,4, 15, -9, 0, -6, 6, -12, 2, 3};
int n=sizeof(a)/sizeof(a[0]);
printf("%d ",n);
GetSubArray(a,n,0,0);
}