[algogeeks] Re: Minimum number of jumps to reach end

2012-01-26 Thread Don
From position i, move n such that n = arr[i] and n+arr[i+n] is
maximized.
Don

On Jan 25, 11:03 pm, Sanjay Rajpal sanjay.raj...@live.in wrote:
 Given an array of integers where each element represents the max number of
 steps that can be made forward from that element. Write a function to
 return the minimum number of jumps to reach the end of the array (starting
 from the first element). If an element is 0, then cannot move through that
 element.

 Example:

 *Input: arr[] = {1, 3, 5, 8, 9, 2, 6, 7, 6, 8, 9}
 Output: 3 (1- 3 - 8 -9)*

 *
 Sanjay Kumar
 B.Tech Final Year
 Department of Computer Engineering
 National Institute of Technology Kurukshetra
 Kurukshetra - 136119
 Haryana, India
 Contact: +91-8053566286
 *

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] C o/p help

2012-01-26 Thread rahul sharma
#includestdio.h
#includeconio.h
void fun(char **);

int main()
{
char *argv[]={ab,cd,de,fg};
fun(argv);
getch();
return 0;
}

void fun(char **p)
{
 char *t;
 t=(p+=sizeof(int))[-1];
 printf(%s\n,t);
}

o/p: fg

can nyone xplain

the 2nd statement in fun?

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C o/p help

2012-01-26 Thread atul anand
output depends on sizeof(int)so it may be different if you run on
different compilers.

considering *sizeof(int) = 2;*

argv[] is array of pointers.
  (p+=sizeof(int))[-1];
p=p+2 // 2=sizeof(int);

now p will be pointing at index *argv[2];
then you are doing

p=p-1;

i.e p will point to *argv[1]

hence output will be
o/p = cd

On Thu, Jan 26, 2012 at 10:53 PM, rahul sharma rahul23111...@gmail.comwrote:

 #includestdio.h
 #includeconio.h
 void fun(char **);

 int main()
 {
 char *argv[]={ab,cd,de,fg};
 fun(argv);
 getch();
 return 0;
 }

 void fun(char **p)
 {
  char *t;
  t=(p+=sizeof(int))[-1];
  printf(%s\n,t);
 }

 o/p: fg

 can nyone xplain

 the 2nd statement in fun?

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C o/p help

2012-01-26 Thread atul anand
btw your compiler has sizeof(int)=4;
thats why o/p = fg

On Thu, Jan 26, 2012 at 11:09 PM, atul anand atul.87fri...@gmail.comwrote:

 output depends on sizeof(int)so it may be different if you run on
 different compilers.

 considering *sizeof(int) = 2;*

 argv[] is array of pointers.
   (p+=sizeof(int))[-1];
 p=p+2 // 2=sizeof(int);

 now p will be pointing at index *argv[2];
 then you are doing

 p=p-1;

 i.e p will point to *argv[1]

 hence output will be
 o/p = cd

 On Thu, Jan 26, 2012 at 10:53 PM, rahul sharma rahul23111...@gmail.comwrote:

 #includestdio.h
 #includeconio.h
 void fun(char **);

 int main()
 {
 char *argv[]={ab,cd,de,fg};
 fun(argv);
 getch();
 return 0;
 }

 void fun(char **p)
 {
  char *t;
  t=(p+=sizeof(int))[-1];
  printf(%s\n,t);
 }

 o/p: fg

 can nyone xplain

 the 2nd statement in fun?

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C o/p help

2012-01-26 Thread rahul sharma
[-1] in end is same as -1 ??

On Thu, Jan 26, 2012 at 11:11 PM, atul anand atul.87fri...@gmail.comwrote:

 btw your compiler has sizeof(int)=4;
 thats why o/p = fg

 On Thu, Jan 26, 2012 at 11:09 PM, atul anand atul.87fri...@gmail.comwrote:

 output depends on sizeof(int)so it may be different if you run on
 different compilers.

 considering *sizeof(int) = 2;*

 argv[] is array of pointers.
   (p+=sizeof(int))[-1];
 p=p+2 // 2=sizeof(int);

 now p will be pointing at index *argv[2];
 then you are doing

 p=p-1;

 i.e p will point to *argv[1]

 hence output will be
 o/p = cd

 On Thu, Jan 26, 2012 at 10:53 PM, rahul sharma 
 rahul23111...@gmail.comwrote:

 #includestdio.h
 #includeconio.h
 void fun(char **);

 int main()
 {
 char *argv[]={ab,cd,de,fg};
 fun(argv);
 getch();
 return 0;
 }

 void fun(char **p)
 {
  char *t;
  t=(p+=sizeof(int))[-1];
  printf(%s\n,t);
 }

 o/p: fg

 can nyone xplain

 the 2nd statement in fun?

  --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Kurukshetra Online Debugging Prelims today

2012-01-26 Thread prakash y
Hi guys,
I tried to participate in this contest and solved the first problem KDEBUG1
in Java. But I got time limit exceeded error.
I observed that most of the coders use C/C++, and I know that Java is
slower when compared to C/C++.

My algorithm might be inefficient. But before that I just want to know
whether Java is prefered or not especially when we compete in these types
of coding contests.
If not, please suggest me a good editor and programming environment.

Please don't mind if it's not related to this group. But please help me,
because I do not want to be disqualified next time.
Thanks in advance.


On Thu, Jan 26, 2012 at 1:02 PM, Rishi msrishiku...@gmail.com wrote:

 The online prelim round of  the Debugging event of *Kurukshetra *12, the
 annual technical symposium of* College of Engineering Guindy, Anna
 University* will be held on *26 January, 2012, 7.00 pm IST *at
 http://www.spoj.pl/KDEBUG/
 Participate in teams of three. Teams landing at top of this online contest
 will be directly qualified to the second round of onsite Debugging event of
 Kurukshetra 12.  Please share the info with your friends :)

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To view this discussion on the web visit
 https://groups.google.com/d/msg/algogeeks/-/20we4Ksf85QJ.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C o/p help

2012-01-26 Thread atul anand
think in terms of pointers...

they are same :-

p[-1] = *(p - 1)

On Thu, Jan 26, 2012 at 11:15 PM, rahul sharma rahul23111...@gmail.comwrote:

 [-1] in end is same as -1 ??


 On Thu, Jan 26, 2012 at 11:11 PM, atul anand atul.87fri...@gmail.comwrote:

 btw your compiler has sizeof(int)=4;
 thats why o/p = fg

 On Thu, Jan 26, 2012 at 11:09 PM, atul anand atul.87fri...@gmail.comwrote:

 output depends on sizeof(int)so it may be different if you run on
 different compilers.

 considering *sizeof(int) = 2;*

 argv[] is array of pointers.
   (p+=sizeof(int))[-1];
 p=p+2 // 2=sizeof(int);

 now p will be pointing at index *argv[2];
 then you are doing

 p=p-1;

 i.e p will point to *argv[1]

 hence output will be
 o/p = cd

 On Thu, Jan 26, 2012 at 10:53 PM, rahul sharma 
 rahul23111...@gmail.comwrote:

 #includestdio.h
 #includeconio.h
 void fun(char **);

 int main()
 {
 char *argv[]={ab,cd,de,fg};
 fun(argv);
 getch();
 return 0;
 }

 void fun(char **p)
 {
  char *t;
  t=(p+=sizeof(int))[-1];
  printf(%s\n,t);
 }

 o/p: fg

 can nyone xplain

 the 2nd statement in fun?

  --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C o/p help

2012-01-26 Thread rahul sharma
@ atul...got nw..thnx

On Thu, Jan 26, 2012 at 11:26 PM, atul anand atul.87fri...@gmail.comwrote:

 think in terms of pointers...

 they are same :-

 p[-1] = *(p - 1)


 On Thu, Jan 26, 2012 at 11:15 PM, rahul sharma rahul23111...@gmail.comwrote:

 [-1] in end is same as -1 ??


 On Thu, Jan 26, 2012 at 11:11 PM, atul anand atul.87fri...@gmail.comwrote:

 btw your compiler has sizeof(int)=4;
 thats why o/p = fg

 On Thu, Jan 26, 2012 at 11:09 PM, atul anand atul.87fri...@gmail.comwrote:

 output depends on sizeof(int)so it may be different if you run on
 different compilers.

 considering *sizeof(int) = 2;*

 argv[] is array of pointers.
   (p+=sizeof(int))[-1];
 p=p+2 // 2=sizeof(int);

 now p will be pointing at index *argv[2];
 then you are doing

 p=p-1;

 i.e p will point to *argv[1]

 hence output will be
 o/p = cd

 On Thu, Jan 26, 2012 at 10:53 PM, rahul sharma rahul23111...@gmail.com
  wrote:

 #includestdio.h
 #includeconio.h
 void fun(char **);

 int main()
 {
 char *argv[]={ab,cd,de,fg};
 fun(argv);
 getch();
 return 0;
 }

 void fun(char **p)
 {
  char *t;
  t=(p+=sizeof(int))[-1];
  printf(%s\n,t);
 }

 o/p: fg

 can nyone xplain

 the 2nd statement in fun?

  --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



  --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Find all longest increasing subsequence of length k

2012-01-26 Thread atul anand
Hi,

suggest an algo which will find all longest increasing sub
sequence of length K.

for eg:-
input : 7 8 9 4 10 11
K=3

output :
7 8 9
7 9 10
7 10 11
8 9 10
8 10 11

desired complexity : O(k*n*logn)

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] pseudi hits and hits

2012-01-26 Thread Ashish Goel
The computer has four slots containing balls that are Red, Yellow, Green,
or Blue. eg RGYB or RRGB..
you as a user trying to guess it. You may for ex guess this as RRGY, if you
guess a color right at same position, it is a hit, however, if you guess
the colour there which is there in original solution(other than hits) but
at some other position is a pseudo hit. eg solution RGGB and guess is YRGB
then 2 hits and 1 pHit.
For each guess you are told the number of hits and pHits.
Given guess and solution, WAP to find the number of hits and pseudo hits.


This is simple, trying to using bit operations, somewhat writing wrong
stuff.

Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Amazon ques

2012-01-26 Thread algoist
Consider 2 temp arrays, B and C

Where B gets updated for every find of 0 and C for every find of 1

i.e if(a[i]==0)
   b[i]+=b[i-1]+1;
   c[i]=c[i-1];
i.e if(a[i]==1)
   c[i]+=c[i-1]+1;
   b[i]=b[i-1];

if(c[i]==b[i])
  update max.

return max.

This is O(N) algo. Is it right or i am missing anything here? 


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/YnKOgIEspAcJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Kurukshetra Online Debugging Prelims today

2012-01-26 Thread saurabh singh
Except few problems where the time limit is too tight a good algorithm is
equally good irrespective of the language.Yes C/C++ are faster than java
but in good competitions like topcoder,codeforces etc. language is not a
problem..For algorithm competitions you don't need a special
environment or editor even notepad and ideone will do.
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Thu, Jan 26, 2012 at 11:17 PM, prakash y yprakash@gmail.com wrote:

 Hi guys,
 I tried to participate in this contest and solved the first problem
 KDEBUG1 in Java. But I got time limit exceeded error.
 I observed that most of the coders use C/C++, and I know that Java is
 slower when compared to C/C++.

 My algorithm might be inefficient. But before that I just want to know
 whether Java is prefered or not especially when we compete in these types
 of coding contests.
 If not, please suggest me a good editor and programming environment.

 Please don't mind if it's not related to this group. But please help me,
 because I do not want to be disqualified next time.
 Thanks in advance.


 On Thu, Jan 26, 2012 at 1:02 PM, Rishi msrishiku...@gmail.com wrote:

 The online prelim round of  the Debugging event of *Kurukshetra *12, the
 annual technical symposium of* College of Engineering Guindy, Anna
 University* will be held on *26 January, 2012, 7.00 pm IST *at
 http://www.spoj.pl/KDEBUG/
 Participate in teams of three. Teams landing at top of this online
 contest will be directly qualified to the second round of onsite Debugging
 event of Kurukshetra 12.  Please share the info with your friends :)

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To view this discussion on the web visit
 https://groups.google.com/d/msg/algogeeks/-/20we4Ksf85QJ.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Kurukshetra Online Debugging Prelims today

2012-01-26 Thread Prakash D
1) Your algorithm must be efficient
2) Your I/O should be fast enough. Use scanf, printf instead of
cin,cout in C++. Use BufferedReader instead of Scanner in case of
Java.
3) Ask such doubts in the space provided in the contest.

On Thu, Jan 26, 2012 at 11:17 PM, prakash y yprakash@gmail.com wrote:
 Please don't mind if it's not related to this group. But please help me,
 because I do not want to be disqualified next time.

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Amazon ques

2012-01-26 Thread Ashish Goel
replace all 0s by -1
keep additional array to get the sumHere at every position of all -1s and
1s.

say you got
 0  1  0 1  0  0  0  0 1 1 1 1  0
-1 1 -1 1 -1 -1 -1 -1 1 1 1 1 -1
sum -1 0 -1 0 -1 -2 -3 -4 -3 -2 -1 0 -1

all equal numbers in sum shows equal zeros and 1s between then including
the end( between two -2 or two -3 or 0 0r -1) so biggest one can be figured
out easily use a hash to store these cum sum, store their first and
last occurrence, walk over to get max diff.





Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652


On Fri, Jan 27, 2012 at 1:48 AM, algoist krishnai...@gmail.com wrote:

 Consider 2 temp arrays, B and C

 Where B gets updated for every find of 0 and C for every find of 1

 i.e if(a[i]==0)
b[i]+=b[i-1]+1;
c[i]=c[i-1];
 i.e if(a[i]==1)
c[i]+=c[i-1]+1;
b[i]=b[i-1];

 if(c[i]==b[i])
   update max.

 return max.

 This is O(N) algo. Is it right or i am missing anything here?


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To view this discussion on the web visit
 https://groups.google.com/d/msg/algogeeks/-/YnKOgIEspAcJ.

 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Amazon ques

2012-01-26 Thread Sanjay Rajpal
+1
*
Sanjay Kumar
B.Tech Final Year
Department of Computer Engineering
National Institute of Technology Kurukshetra
Kurukshetra - 136119
Haryana, India
Contact: +91-8053566286
*



On Thu, Jan 26, 2012 at 6:28 PM, Ashish Goel ashg...@gmail.com wrote:

 replace all 0s by -1
 keep additional array to get the sumHere at every position of all -1s and
 1s.

 say you got
  0  1  0 1  0  0  0  0 1 1 1 1  0
 -1 1 -1 1 -1 -1 -1 -1 1 1 1 1 -1
 sum -1 0 -1 0 -1 -2 -3 -4 -3 -2 -1 0 -1

 all equal numbers in sum shows equal zeros and 1s between then including
 the end( between two -2 or two -3 or 0 0r -1) so biggest one can be figured
 out easily use a hash to store these cum sum, store their first and
 last occurrence, walk over to get max diff.





 Best Regards
 Ashish Goel
 Think positive and find fuel in failure
 +919985813081
 +919966006652



 On Fri, Jan 27, 2012 at 1:48 AM, algoist krishnai...@gmail.com wrote:

 Consider 2 temp arrays, B and C

 Where B gets updated for every find of 0 and C for every find of 1

 i.e if(a[i]==0)
b[i]+=b[i-1]+1;
c[i]=c[i-1];
 i.e if(a[i]==1)
c[i]+=c[i-1]+1;
b[i]=b[i-1];

 if(c[i]==b[i])
   update max.

 return max.

 This is O(N) algo. Is it right or i am missing anything here?


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To view this discussion on the web visit
 https://groups.google.com/d/msg/algogeeks/-/YnKOgIEspAcJ.

 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.