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 = max(arr[i], arr[j]);
cout[arr[i],arr[j]] = ;
coutk\n;
}
return 0;
}

output is :

[5,3] = 5
[1,3] = 3
[1,5] = 5
[9,3] = 9
[9,5] = 9
[9,1] = 9
[0,3] = 3
[0,5] = 5
[0,1] = 1
[0,9] = 9
[4,3] = 4
[4,5] = 5
[4,1] = 4
[4,9] = 9
[4,0] = 4
[-1,3] = 3
[-1,5] = 5
[-1,1] = 1
[-1,9] = 9
[-1,0] = 0
[-1,4] = 4
[7,3] = 7
[7,5] = 7
[7,1] = 7
[7,9] = 9
[7,0] = 7
[7,4] = 7
[7,-1] = 7


On Fri, Sep 2, 2011 at 3:43 PM, WgpShashank shashank7andr...@gmail.comwrote:

 Hi Anup , here is naive approach

 There is a sliding window of size w which is moving from the very left of
 the array to the very right. You can only see the w numbers in the window.
 Each time the sliding window moves rightwards by one position.

 Following is an example:
 The array is [1 3 -1 -3 5 3 6 7], and w is 3.

 Window position Max
 --- -
 [1 3 -1] -3 5 3 6 7 3
 1 [3 -1 -3] 5 3 6 7 3
 1 3 [-1 -3 5] 3 6 7 5
 1 3 -1 [-3 5 3] 6 7 5
 1 3 -1 -3 [5 3 6] 7 6
 1 3 -1 -3 5 [3 6 7] 7

 The obvious solution with run time complexity of O(nw) is which is not
 efficient enough. Every time the window is moved, we have to search for the
 maximum from w elements in the window. where w is size of window  n is size
 of array

 1st Method(Naive Approach)

 Data Structure Used : Array
 Algorithm: A.for all i=0 to n-w+1 (we should have at-least w elements in
 window)
 B.for all j=i to i+w (keep incrementing windows size form left to right)
 C find maximum inn each window  print it or put in array (Auxiliary)

 For more efficient approaches you can have a look here

 http://shashank7s.blogspot.com/2011/06/given-array-and-integer-k-find-maximum.html

 correct me if anything wrong or other approaches you can thing of ?

 Thanks
 Shashank Mani
 Computer Science
 Birla Institute of Technology Mesra

 --
 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/-/m1R83UHfc2UJ.

 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: 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 recursion will run 10 times printing nothing. Then ones it returns
 on the 10th one. It will start printing from 0 to -8 (As i is static).

 On Aug 31, 6:33 pm, ravi maggon maggonr...@gmail.com wrote:
  Ans would be 00, keep in mind that i is static variable.
 
   On Wed, Aug 31, 2011 at 6:59 PM, rohit raman.u...@gmail.com wrote:
   123456789
 
   --
   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/-/OsL6-Vp91qoJ.
   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.
 
  --
 
  Regards
  Ravi Maggon
  Final Year, B.E. CSE
  Thapar University

 --
 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] Re: Static variable

2011-08-31 Thread vishal jain
Yes,

Your ans is very logical...

As i is static it will continue decrementing the value for all printf stored
in stack
 printf(%d,i); ---0
 printf(%d,i);1
printf(%d,i);2
printf(%d,i);3
printf(%d,i);4
printf(%d,i);5
printf(%d,i);6
printf(%d,i);7
printf(%d,i);8



On Wed, Aug 31, 2011 at 8:18 PM, rahul sharma rahul23111...@gmail.comwrote:

 i thnink it works as follow:-


 firstly
 loop goes pushing into stack
 printf(%d,i);
 printf(%d,i);
 printf(%d,i);
 printf(%d,i);
 printf(%d,i);
 printf(%d,i);
 printf(%d,i);
 printf(%d,i);
 printf(%d,i);

 now i is 1
 --i
 means --1
 i=0;

 now all printf are poped printing --i
 from 0;

 m i ryt?



 On Aug 31, 7:40 pm, rahul sharma rahul23111...@gmail.com wrote:
  these two are same
 
  On Aug 31, 7:36 pm, ravi maggon maggonr...@gmail.com wrote:
 
 
 
 
 
 
 
   I check out the code:
 
   #includestdio.h
   main()
   {
   static int i=10;
   while(i0)
   {
   --i;
   main();
   printf(%d,i);
   }
 
   }
 
   if you run this you get 00 as output
 
   but if you run this
 
   #includestdio.h
   main()
   {
   static int i=10;
   while(i0)
   {
   --i;
   main();
   printf(%d,i);
   }
 
   }
 
   You get 0-1-2-3-4-5-6-7-8 as output.
 
   Whats the difference in these?
 
   On Wed, Aug 31, 2011 at 7:52 PM, aditi garg aditi.garg.6...@gmail.com
 wrote:
 
@abhishek: y till -8?
 
On Wed, 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);
}
return 0;
}
 
On Wed, Aug 31, 2011 at 7:48 PM, Abhishek Mallick 
abhishek.mallick2...@gmail.com wrote:
 
The recursion will run 10 times printing nothing. Then ones it
 returns
on the 10th one. It will start printing from 0 to -8 (As i is
 static).
 
On Aug 31, 6:33 pm, ravi maggon maggonr...@gmail.com wrote:
 Ans would be 00, keep in mind that i is static variable.
 
  On Wed, Aug 31, 2011 at 6:59 PM, rohit raman.u...@gmail.com
 wrote:
  123456789
 
  --
  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/-/OsL6-Vp91qoJ.
  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.
 
 --
 
 Regards
 Ravi Maggon
 Final Year, B.E. CSE
 Thapar University
 
--
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.
 
--
Aditi Garg
Undergraduate Student
Electronics  Communication Divison
NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
Sector 3, Dwarka
New Delhi
 
 --
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.
 
   --
 
   Regards
   Ravi Maggon
   Final Year, B.E. CSE
   Thapar University

 --
 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] Re: Static variable

2011-08-31 Thread vishal jain
because i is static..

On Wed, Aug 31, 2011 at 8:23 PM, aditya kumar
aditya.kumar130...@gmail.comwrote:

 @rahul : wen the values are pushed on to the stack they are like 9 , 8 , 7
 , till 0 so when they pop out shouldnt it be follwing the order 0 1 2 till 9
 . i realy dont know why the o/p is 0 -1 -2 and so on ??


 On Wed, Aug 31, 2011 at 8:18 PM, rahul sharma rahul23111...@gmail.comwrote:

 i thnink it works as follow:-


 firstly
 loop goes pushing into stack
 printf(%d,i);
 printf(%d,i);
 printf(%d,i);
 printf(%d,i);
 printf(%d,i);
 printf(%d,i);
 printf(%d,i);
 printf(%d,i);
 printf(%d,i);

 now i is 1
 --i
 means --1
 i=0;

 now all printf are poped printing --i
 from 0;

 m i ryt?



 On Aug 31, 7:40 pm, rahul sharma rahul23111...@gmail.com wrote:
  these two are same
 
  On Aug 31, 7:36 pm, ravi maggon maggonr...@gmail.com wrote:
 
 
 
 
 
 
 
   I check out the code:
 
   #includestdio.h
   main()
   {
   static int i=10;
   while(i0)
   {
   --i;
   main();
   printf(%d,i);
   }
 
   }
 
   if you run this you get 00 as output
 
   but if you run this
 
   #includestdio.h
   main()
   {
   static int i=10;
   while(i0)
   {
   --i;
   main();
   printf(%d,i);
   }
 
   }
 
   You get 0-1-2-3-4-5-6-7-8 as output.
 
   Whats the difference in these?
 
   On Wed, Aug 31, 2011 at 7:52 PM, aditi garg 
 aditi.garg.6...@gmail.comwrote:
 
@abhishek: y till -8?
 
On Wed, 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);
}
return 0;
}
 
On Wed, Aug 31, 2011 at 7:48 PM, Abhishek Mallick 
abhishek.mallick2...@gmail.com wrote:
 
The recursion will run 10 times printing nothing. Then ones it
 returns
on the 10th one. It will start printing from 0 to -8 (As i is
 static).
 
On Aug 31, 6:33 pm, ravi maggon maggonr...@gmail.com wrote:
 Ans would be 00, keep in mind that i is static variable.
 
  On Wed, Aug 31, 2011 at 6:59 PM, rohit raman.u...@gmail.com
 wrote:
  123456789
 
  --
  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/-/OsL6-Vp91qoJ.
  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.
 
 --
 
 Regards
 Ravi Maggon
 Final Year, B.E. CSE
 Thapar University
 
--
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.
 
--
Aditi Garg
Undergraduate Student
Electronics  Communication Divison
NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
Sector 3, Dwarka
New Delhi
 
 --
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.
 
   --
 
   Regards
   Ravi Maggon
   Final Year, B.E. CSE
   Thapar University

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

[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 is bigger.

P *We have a responsibility to the environment.*

*Before printing this e-mail or any other document, let's ask
ourselves whether we need a hard copy.*

-- 
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] 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 @ jainvish.blogspot.com
Success taste better when target achieved is bigger.

P *We have a responsibility to the environment.*

*Before printing this e-mail or any other document, let's ask
ourselves whether we need a hard copy.*




On Fri, Jul 22, 2011 at 10:19 PM, aditi garg aditi.garg.6...@gmail.comwrote:

 I think this can be answered like dis...
 let us say that the persons have decided amongst themselves that if the the
 number of people wearing white in front of dem is even he wud say white and
 if odd he wud say black
 Now suppose the 100th person counts the number of hats and finds it to be
 even... he wud say white...
 now the 99th person will do the same...if he still finds the number to be
 even and since the 100th person sed white(i.e even) he would say black...now
 if the 100th person had sed black (ie odd white) and the count comes out to
 be even thus 99 wud be wearing a white hat...
 Now that 98th person knows dat 99 had sed the correct hat and using the
 same method can say the correct hat color...thus all can be saved except the
 100th prisoner...
 Also note dat the 100th prisoner also has a 50% chance to survive...

 Hope dis helps :)


 On Fri, Jul 22, 2011 at 10:05 PM, Shubham Maheshwari 
 shubham@gmail.com wrote:

 could some1 plz post the xplainations ...


 On Fri, Jul 22, 2011 at 8:04 PM, Pankaj jatka.oppimi...@gmail.comwrote:

 Chetan,

 No. How could you relate this problem with that? Do you find something
 similar?

 ~
 Pankaj


 On Fri, Jul 22, 2011 at 8:01 PM, chetan kapoor 
 chetankapoor...@gmail.com wrote:

 josehus problem???


 On Fri, Jul 22, 2011 at 7:57 PM, Pankaj jatka.oppimi...@gmail.comwrote:

 Skipp Riddle,
 Yes.
 100th prisoner will risk his life. Similar puzzle was discuss recently.
 Does anyone remember the name or thread?


 ~
 Pankaj


 On Fri, Jul 22, 2011 at 7:55 PM, SkRiPt KiDdIe anuragmsi...@gmail.com
  wrote:

 Worst case 99 get released.
 Is that correct..?

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




 --
 Aditi Garg
 Undergraduate Student
 Electronics  Communication Divison
 NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
 Sector 3, Dwarka
 New Delhi

 9718388816

  --
 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] Interview Question: Puzzle: Probability

2011-06-22 Thread Vishal Jain
Navneet,

Your answer is correct, it would have been great if you could have explained
it for others.
I myself took good time to understand it...

Here is the answer

http://exploreriddles.blogspot.com/2011/06/interview-questions-puzzle.html


To maximize the chances of retrieving Red Ball, it is mandatory to reduce
the chances of retrieving Blue ball.

To reduce the chances.

1. It is possible to put all the black ball in one jar. It will reduce the
probability of retrieving black ball to half.

2. Now to reduce the probability of withdrawing Blue balls, need to maximize
number of red balls in the jar with blue balls. Maximum red balls we have is
50.

So based on above 2 points...

one jar can have 1 Red ball, and other will contain rest 99 balls.

So probability of choosing red ball is
(Probability of Choosing Jar 1)*(Probability of Choosing Red Ball From jar
1) + (Probability 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 this e-mail or any other document, let's ask
ourselves whether we need a hard copy.*




On Tue, Jun 14, 2011 at 7:47 PM, Navneet Gupta navneetn...@gmail.comwrote:

 Put one red ball in one jar and rest 99 balls in other jar.

 Probability in that case is 1/2*1 + 1/2*49//99

 On Tue, Jun 14, 2011 at 7:45 PM, Vishal Jain jainv...@gmail.com wrote:

 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 to the environment.*

 *Before printing this e-mail or any other document, let's ask ourselves 
 whether we need a hard copy.*


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




 --
 --Navneet

  --
 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] 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 to the environment.*

*Before printing this e-mail or any other document, let's ask
ourselves whether we need a hard copy.*

-- 
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] Google Interview Question

2011-05-29 Thread Vishal Jain
Can this work...

Lets say I have following numbers
8 9 7 4 2 121 23 21 24 27 35 79 2334 6785

Now repeat the last number to make all the number of equal length...
     1211 2333 2111 2444 2777 3555 7999 2334 6785

Sort the following numbers in descending order.
  7999  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 @ jainvish.blogspot.com
Success taste better when target achieved is bigger.

P *We have a responsibility to the environment.*

*Before printing this e-mail or any other document, let's ask
ourselves whether we need a hard copy.*




On Sun, May 29, 2011 at 12:58 PM, Ashish Goel ashg...@gmail.com wrote:

 Radix/bucket sort..

 won't that help?

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



 On Fri, May 27, 2011 at 7:15 PM, adityasir...@gmail.com wrote:

 how about this case:

  9, 100 - 9100
 100 9
 9100

  2, 3, 9, 78 --
  78 9 3 2
 9 78 3 2

 I guess solution should be:-
 sort the array of numbers in an ascending order and then check for the
 first element in the array, if there is any other element greater than it,
 shift all the elements one right and place that element in the left most
 space.


 On Fri, May 27, 2011 at 9:37 AM, wujin chen wujinchen...@gmail.comwrote:

 @Piyush, how to deal with this case :100 , 10


 2011/5/27 Piyush Sinha ecstasy.piy...@gmail.com

 we can work out if we sort according to the leftmost integer

 On 5/27/11, adityasir...@gmail.com adityasir...@gmail.com wrote:
  are you kidding me. Just simple sort wont work.
 
  On Fri, May 27, 2011 at 9:31 AM, radha krishnan 
  radhakrishnance...@gmail.com wrote:
 
  sort :)
 
 
  On Fri, May 27, 2011 at 6:57 PM, ross jagadish1...@gmail.com
 wrote:
 
  Hi all,
 
  Given an array of elements find the largest possible number that can
  be formed by using the elements of the array.
 
  eg: 10 9
  ans: 910
 
  2 3 5 78
 
  ans: 78532
 
  100 9
 
  ans: 9100
 
  --
  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.
 
 


 --
 *Piyush Sinha*
 *IIIT, Allahabad*
 *+91-8792136657*
 *+91-7483122727*
 *https://www.facebook.com/profile.php?id=10655377926 *

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

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
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 this e-mail or any other document, let's ask
ourselves whether we need a hard copy.*




On Sun, May 29, 2011 at 6:46 AM, saurabh singh saurab...@gmail.com wrote:

 In fact we can...though not directly..SInce every number can be broken down
 as facotrs of primeUse that property


 On Sun, May 29, 2011 at 1:12 AM, Tushar Bindal tushicom...@gmail.comwrote:

 that theorem is for odd primes
 9 is not an odd prime
 so we can;t apply this theorem


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




 --
 Saurabh Singh
 B.Tech (Computer Science)
 MNNIT ALLAHABAD


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