Re: [algogeeks] Find the Max from each sub-array of size k

2011-09-02 Thread vishal jain
I made a small program with window size k = 2; int max(int n, int m) { if ( n m ) return n; else return m; } int main() { int arr[8]={3,5,1,9,0,4,-1,7}; int i,j; for (i=0;i!=j i=7;i++) for (j=0;j!=i j=7; j++) { int k =

Re: [algogeeks] Re: Static variable

2011-08-31 Thread vishal jain
I executed on linux machine.. I am gettign output 0-1-2-3-4-5-6-7-8 :( for code int main() { static int i=10; while(--i0) { main(); printf(%d,i); } return 0; } On Wed, Aug 31, 2011 at 7:48 PM, Abhishek Mallick abhishek.mallick2...@gmail.com wrote: The

Re: [algogeeks] Re: Static variable

2011-08-31 Thread vishal jain
, vishal jain vishal.l...@gmail.com wrote: I executed on linux machine.. I am gettign output 0-1-2-3-4-5-6-7-8 :( for code int main() { static int i=10; while(--i0) { main(); printf(%d,i); } return 0

Re: [algogeeks] Re: Static variable

2011-08-31 Thread vishal jain
, Aug 31, 2011 at 7:50 PM, vishal jain vishal.l...@gmail.com wrote: I executed on linux machine.. I am gettign output 0-1-2-3-4-5-6-7-8 :( for code int main() { static int i=10; while(--i0) { main(); printf(%d,i

[algogeeks] Interview Puzzle - 100 Prisoners and Caps

2011-07-22 Thread Vishal Jain
Hi All, In my last interview(given few months back), I was asked the following puzzle.. http://goo.gl/jrnpc Could you please tell me the solution for the same? Thanks Regards Vishal Jain MNo: +91-9540611889 Tweet @jainvis Blog @ jainvish.blogspot.com Success taste better when target achieved

Re: [algogeeks] Interview Puzzle - 100 Prisoners and Caps

2011-07-22 Thread Vishal Jain
I think Aditi's solution is correct. I was doing the same thing using XOR function... So basically I was saying to use XOR and interviewer was asking for something better... I could not find this solution... Thanks Aditi. Thanks Regards Vishal Jain MNo: +91-9540611889 Tweet @jainvis Blog

Re: [algogeeks] Interview Question: Puzzle: Probability

2011-06-22 Thread Vishal Jain
of Choosing Jar 2)*(Probability of Choosing Red Ball From jar 2) (1/2)*(1) + (1/2)(49/99) Thanks Regards Vishal Jain MNo: +91-9540611889 Tweet @jainvis Blog @ jainvish.blogspot.com Success taste better when target achieved is bigger. P *We have a responsibility to the environment.* *Before printing

[algogeeks] Interview Question: Puzzle: Probability

2011-06-14 Thread Vishal Jain
Folks, This question was asked during a screening process of a product based company. Please answer. http://exploreriddles.blogspot.com/2011/06/interview-questions-puzzle.html Thanks Regards Vishal Jain Success taste better when target achieved is bigger. P *We have a responsibility

Re: [algogeeks] Google Interview Question

2011-05-29 Thread Vishal Jain
6785 ... Now merge the numbers based on their actual value. 987976785.. I have not testing this entirely, but after seeing solution(Multiplying by 10) at top, I though this might work better. Thanks Regards Vishal Jain MNo: +91-9540611889 Tweet @jainvis Blog

Re: [algogeeks] Re: spoj--two squares problem

2011-05-29 Thread Vishal Jain
Hi Saurabh, Can you try it for 10? Could not really understand, what are you gonna communicate? 10 = 2*5 (2^2 + 1^2 )*(1*2 + 1^2)... If with this logic you are saying 10 is prime then all numbers divisible by 5 should be prime. Could you elaborate your answer more? Thanks Regards Vishal Jain