Challenging programming question

Started by
32 comments, last by RajanSky 21 years, 7 months ago
Well, if we are trying to solve it when there are both positive and negative integers in the array, than DrPizza''s solution is entirely correct.

However, the intent in the problem statement looks like it means it *can* contain both positive and negative integers. However, if it''s truly "both" then my solution is completely unneccesary. But it was fun nonetheless .
Advertisement
quote:Original post by Flarelocke
The only case where it doesn't work is when there's an array of nothing but negatives, which falls outside the domain of the problem. Therefore, it works.

Of course it does. The array has n negative numbers and 0 positive ones.

In any case, the question is supposed to ask for the maximum segment sum; the list of questions is (allegedly) a list used by MS.

That said, I would be quite surprised to be asked such a question in an interview; the solution to such a problem is generally "look it up in a book".


[edited by - DrPizza on September 16, 2002 10:51:09 AM]
char a[99999],*p=a;int main(int c,char**V){char*v=c>0?1[V]:(char*)V;if(c>=0)for(;*v&&93!=*v;){62==*v&&++p||60==*v&&--p||43==*v&&++*p||45==*v&&--*p||44==*v&&(*p=getchar())||46==*v&&putchar(*p)||91==*v&&(*p&&main(0,(char**)(--v+2))||(v=(char*)main(-1,(char**)++v)-1));++v;}else for(c=1;c;c+=(91==*v)-(93==*v),++v);return(int)v;}  /*** drpizza@battleaxe.net ***/
where is this list of questions?
I found the list of questions from Vince Scheib''s website. He wrote a Gamasutra article called "Approaching Internships in the Game Industry" and it had a link to his site so I was just checking it out.. Anyways the link is here:

http://www.cs.unc.edu/~scheib/work/questions/index.html

Raj

This topic is closed to new replies.

Advertisement