Re: [algogeeks] how to delete a substring from a given string.???

2010-12-23 Thread Ankur Khurana
you can use direct c++ tem-plates. anyways ,
in c format.  use strstr() to find the pointer to the substring
present in the main given string. then just shift all the contents
after the subtring to the starting of your substring.

On Thu, Dec 23, 2010 at 3:47 AM, Ajay Kumar ajay...@gmail.com wrote:
 i dont noe the logic..help!!!

 --
 You received this message because you are subscribed to the Google Groups 
 Algorithm Geeks group.
 To post to this group, send email to algoge...@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 algoge...@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] Array Ranking Problem

2010-12-23 Thread Davin
Problem Definition : Find minimum time X from set of questions to pass
the exam : Input :  Array of Marks [0, n-1] corresponding Array of
Time of Each Questions[0, n-1].  Thanks for help in advance.

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@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] Re: Array Ranking Problem

2010-12-23 Thread juver++
Please clarify the problem statement. Provide example.
From the first view problem seems to be unclear.

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@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] Re: Amazon Interview Question about Linked Lists

2010-12-23 Thread soundar
@shiva , U didn't check for the cycles.Since in question it is never
mentioned about cycles u can add few steps to check cycles.
(eg)

1  3 - 5 
|  |
|  |
|  |
4-3--3

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@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] Re: Array Ranking Problem

2010-12-23 Thread Davin
Marks for Questions(1,6): {10,15,20,25,10,20}
Time for Each Questions(1,6) : { 2, 4,3,4, 2,4}
Passing Marks : 40 Out of 100

Find Questions with minimum time to pass the exam?

On Dec 23, 7:04 pm, juver++ avpostni...@gmail.com wrote:
 Please clarify the problem statement. Provide example.
 From the first view problem seems to be unclear.

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@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: difference x

2010-12-23 Thread snehal jain
bhupendra's   solution  is right..

On Thu, Dec 23, 2010 at 1:04 PM, jai gupta sayhelloto...@gmail.com wrote:

 make  another array(B) from (A) with all elements negated
 now find one element from B and one from A  whose sum is x or -x. This can
 ofcourse be done in O(n).

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@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: Array Ranking Problem

2010-12-23 Thread snehal jain
hint : use dp

On Thu, Dec 23, 2010 at 8:30 PM, Davin dkthar...@googlemail.com wrote:

 Marks for Questions(1,6): {10,15,20,25,10,20}
 Time for Each Questions(1,6) : { 2, 4,3,4, 2,4}
 Passing Marks : 40 Out of 100

 Find Questions with minimum time to pass the exam?

 On Dec 23, 7:04 pm, juver++ avpostni...@gmail.com wrote:
  Please clarify the problem statement. Provide example.
  From the first view problem seems to be unclear.

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@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] Re: Array Ranking Problem

2010-12-23 Thread Davin
Thanks for reply. I am looking for O(n) for solution.

Davin

On Dec 23, 8:29 pm, snehal jain learner@gmail.com wrote:
 hint : use dp







 On Thu, Dec 23, 2010 at 8:30 PM, Davin dkthar...@googlemail.com wrote:
  Marks for Questions(1,6): {10,15,20,25,10,20}
  Time for Each Questions(1,6) : { 2, 4,3,4, 2,4}
  Passing Marks : 40 Out of 100

  Find Questions with minimum time to pass the exam?

  On Dec 23, 7:04 pm, juver++ avpostni...@gmail.com wrote:
   Please clarify the problem statement. Provide example.
   From the first view problem seems to be unclear.

  --
  You received this message because you are subscribed to the Google Groups
  Algorithm Geeks group.
  To post to this group, send email to algoge...@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@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: Array Ranking Problem

2010-12-23 Thread Ankur Khurana
it is just like 0/1 knapsack problem with maximum weight of knapsack
as 40. but in this case that is minimum that we have to calculate.
calculate marks/time for every element . then try finding the elements
with max value/time to fulfill the quota of marks. i dont know if this
can be done in O(n) but it can be certainly done in nlogn. any other
views ?

On Thu, Dec 23, 2010 at 9:03 PM, Davin dkthar...@googlemail.com wrote:
 Thanks for reply. I am looking for O(n) for solution.

 Davin

 On Dec 23, 8:29 pm, snehal jain learner@gmail.com wrote:
 hint : use dp







 On Thu, Dec 23, 2010 at 8:30 PM, Davin dkthar...@googlemail.com wrote:
  Marks for Questions(1,6): {10,15,20,25,10,20}
  Time for Each Questions(1,6) : { 2, 4,3,4, 2,4}
  Passing Marks : 40 Out of 100

  Find Questions with minimum time to pass the exam?

  On Dec 23, 7:04 pm, juver++ avpostni...@gmail.com wrote:
   Please clarify the problem statement. Provide example.
   From the first view problem seems to be unclear.

  --
  You received this message because you are subscribed to the Google Groups
  Algorithm Geeks group.
  To post to this group, send email to algoge...@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@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 algoge...@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: TopCoder Bad Neighbour

2010-12-23 Thread mohit ranjan
@Amit,

please refer
http://www.topcoder.com/tc?module=Staticd1=match_editorialsd2=tccc04_online_rd_4

the recurrence relations is
f(x) = max(f(x-2)+element[x], f(x-3)+element[x-1])

you are missing the 2nd part here


Mohit


On Wed, Dec 22, 2010 at 9:55 PM, Amit Jaspal amitjaspal...@gmail.comwrote:

 Hi all,

 I was trying this question and I got the jist of it I guess but still its
 not getting accepted

 Can anybody tell me what am I doing wrong??


 
 int BadNeighbors::maxDonations(vector int d) {

 int s=d.size();

 if(s==1){
 return d[0];
 }

 int i,j,k,ans1=0,ans2=0;
 int dp1[10],dp2[10];
 dp1[0]=d[0];
 dp1[1]=d[1];

 // Breaking the circular list into 2 linear lists.


 // Processing the first list.
 for(i=2;is-1;i++){
 dp1[i]=max(dp1[i-1],(dp1[i-2]+d[i]));
 }
 ans1=dp1[s-2];


 // Processing the second list.
 dp2[1]=d[1];
 dp2[2]=d[2];
 for(i=3;is;i++){
 dp2[i]=max(dp2[i-1],(dp2[i-2]+d[i]));
 }
 ans2=dp2[s-1];

 return max(ans1,ans2);

}


 *


 On Wed, Dec 22, 2010 at 9:00 PM, mohit ranjan shoonya.mo...@gmail.comwrote:

 Ok, I got the recurrence relation at

 http://www.topcoder.com/tc?module=Staticd1=match_editorialsd2=tccc04_online_rd_4


 Mohit



 On Wed, Dec 22, 2010 at 8:33 PM, mohit ranjan shoonya.mo...@gmail.comwrote:

 Hi All,

 Can anybody help me with some hint for
 http://www.topcoder.com/stat?c=problem_statementpm=2402rd=5009


 Mohit


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




 --
 Amit Jaspal
 Btech IT IIIT- Allahabad

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@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: Array Ranking Problem

2010-12-23 Thread Nikhil Agarwal
@ankur can you hint your nlogn solution?

On Thu, Dec 23, 2010 at 9:08 PM, Ankur Khurana ankur.kkhur...@gmail.comwrote:

 it is just like 0/1 knapsack problem with maximum weight of knapsack
 as 40. but in this case that is minimum that we have to calculate.
 calculate marks/time for every element . then try finding the elements
 with max value/time to fulfill the quota of marks. i dont know if this
 can be done in O(n) but it can be certainly done in nlogn. any other
 views ?

 On Thu, Dec 23, 2010 at 9:03 PM, Davin dkthar...@googlemail.com wrote:
  Thanks for reply. I am looking for O(n) for solution.
 
  Davin
 
  On Dec 23, 8:29 pm, snehal jain learner@gmail.com wrote:
  hint : use dp
 
 
 
 
 
 
 
  On Thu, Dec 23, 2010 at 8:30 PM, Davin dkthar...@googlemail.com
 wrote:
   Marks for Questions(1,6): {10,15,20,25,10,20}
   Time for Each Questions(1,6) : { 2, 4,3,4, 2,4}
   Passing Marks : 40 Out of 100
 
   Find Questions with minimum time to pass the exam?
 
   On Dec 23, 7:04 pm, juver++ avpostni...@gmail.com wrote:
Please clarify the problem statement. Provide example.
From the first view problem seems to be unclear.
 
   --
   You received this message because you are subscribed to the Google
 Groups
   Algorithm Geeks group.
   To post to this group, send email to algoge...@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 algogeeks%2bunsubscr...@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 algoge...@googlegroups.com.
  To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Thanks  Regards
Nikhil Agarwal
Senior Undergraduate
Computer Science  Engineering,
National Institute Of Technology, Durgapur,India
http://tech-nikk.blogspot.com
http://beta.freshersworld.com/communities/nitd

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@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: difference x

2010-12-23 Thread Nikhil Agarwal
Divya and saurabh please post your working solution different from that of
Bhupen's.

On Thu, Dec 23, 2010 at 1:04 PM, jai gupta sayhelloto...@gmail.com wrote:

 make  another array(B) from (A) with all elements negated
 now find one element from B and one from A  whose sum is x or -x. This can
 ofcourse be done in O(n).

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




-- 
Thanks  Regards
Nikhil Agarwal
Senior Undergraduate
Computer Science  Engineering,
National Institute Of Technology, Durgapur,India
http://tech-nikk.blogspot.com
http://beta.freshersworld.com/communities/nitd

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@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: difference x

2010-12-23 Thread Amit Jaspal
@ jai nice solution

I think for O(n) solution we will have to use extra array.
Otherwise we will have to do this in O(nlogn).
Correct me if i am wrong.


On Thu, Dec 23, 2010 at 1:04 PM, jai gupta sayhelloto...@gmail.com wrote:

 make  another array(B) from (A) with all elements negated
 now find one element from B and one from A  whose sum is x or -x. This can
 ofcourse be done in O(n).

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




-- 
Amit Jaspal
Btech IT IIIT- Allahabad

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@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: Array Ranking Problem

2010-12-23 Thread Ankur Khurana
wverything i mentioned above can be done in O(n) but sorting part is
nlogn . so that is what i was saying. can you specify where i was not
clear ?

On Thu, Dec 23, 2010 at 9:22 PM, Nikhil Agarwal
nikhil.bhoja...@gmail.com wrote:
 @ankur can you hint your nlogn solution?

 On Thu, Dec 23, 2010 at 9:08 PM, Ankur Khurana ankur.kkhur...@gmail.com
 wrote:

 it is just like 0/1 knapsack problem with maximum weight of knapsack
 as 40. but in this case that is minimum that we have to calculate.
 calculate marks/time for every element . then try finding the elements
 with max value/time to fulfill the quota of marks. i dont know if this
 can be done in O(n) but it can be certainly done in nlogn. any other
 views ?

 On Thu, Dec 23, 2010 at 9:03 PM, Davin dkthar...@googlemail.com wrote:
  Thanks for reply. I am looking for O(n) for solution.
 
  Davin
 
  On Dec 23, 8:29 pm, snehal jain learner@gmail.com wrote:
  hint : use dp
 
 
 
 
 
 
 
  On Thu, Dec 23, 2010 at 8:30 PM, Davin dkthar...@googlemail.com
  wrote:
   Marks for Questions(1,6): {10,15,20,25,10,20}
   Time for Each Questions(1,6) : { 2, 4,3,4, 2,4}
   Passing Marks : 40 Out of 100
 
   Find Questions with minimum time to pass the exam?
 
   On Dec 23, 7:04 pm, juver++ avpostni...@gmail.com wrote:
Please clarify the problem statement. Provide example.
From the first view problem seems to be unclear.
 
   --
   You received this message because you are subscribed to the Google
   Groups
   Algorithm Geeks group.
   To post to this group, send email to algoge...@googlegroups.com.
   To unsubscribe from this group, send email to
  
   algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@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 algoge...@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.




 --
 Thanks  Regards
 Nikhil Agarwal
 Senior Undergraduate
 Computer Science  Engineering,
 National Institute Of Technology, Durgapur,India
 http://tech-nikk.blogspot.com
 http://beta.freshersworld.com/communities/nitd


 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@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 algoge...@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: Array Ranking Problem

2010-12-23 Thread Ankur Khurana
i will try to elaborate or rewrite tat part

On Thu, Dec 23, 2010 at 10:25 PM, Ankur Khurana
ankur.kkhur...@gmail.com wrote:
 wverything i mentioned above can be done in O(n) but sorting part is
 nlogn . so that is what i was saying. can you specify where i was not
 clear ?

 On Thu, Dec 23, 2010 at 9:22 PM, Nikhil Agarwal
 nikhil.bhoja...@gmail.com wrote:
 @ankur can you hint your nlogn solution?

 On Thu, Dec 23, 2010 at 9:08 PM, Ankur Khurana ankur.kkhur...@gmail.com
 wrote:

 it is just like 0/1 knapsack problem with maximum weight of knapsack
 as 40. but in this case that is minimum that we have to calculate.
 calculate marks/time for every element . then try finding the elements
 with max value/time to fulfill the quota of marks. i dont know if this
 can be done in O(n) but it can be certainly done in nlogn. any other
 views ?

 On Thu, Dec 23, 2010 at 9:03 PM, Davin dkthar...@googlemail.com wrote:
  Thanks for reply. I am looking for O(n) for solution.
 
  Davin
 
  On Dec 23, 8:29 pm, snehal jain learner@gmail.com wrote:
  hint : use dp
 
 
 
 
 
 
 
  On Thu, Dec 23, 2010 at 8:30 PM, Davin dkthar...@googlemail.com
  wrote:
   Marks for Questions(1,6): {10,15,20,25,10,20}
   Time for Each Questions(1,6) : { 2, 4,3,4, 2,4}
   Passing Marks : 40 Out of 100
 
   Find Questions with minimum time to pass the exam?
 
   On Dec 23, 7:04 pm, juver++ avpostni...@gmail.com wrote:
Please clarify the problem statement. Provide example.
From the first view problem seems to be unclear.
 
   --
   You received this message because you are subscribed to the Google
   Groups
   Algorithm Geeks group.
   To post to this group, send email to algoge...@googlegroups.com.
   To unsubscribe from this group, send email to
  
   algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@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 algoge...@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.




 --
 Thanks  Regards
 Nikhil Agarwal
 Senior Undergraduate
 Computer Science  Engineering,
 National Institute Of Technology, Durgapur,India
 http://tech-nikk.blogspot.com
 http://beta.freshersworld.com/communities/nitd


 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@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 algoge...@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] Find the element with more than n/k occurrences

2010-12-23 Thread Saurabh Koar
ya,u r right.U can find max and min by O(n) time.Bt I already
mentioned that there will be additional space complexity.If u want to
avoid that u can follow juver++ approach other than ur solution.

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@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: Array Ranking Problem

2010-12-23 Thread Nikhil Agarwal
@Ankur Now its clear.:)

On Thu, Dec 23, 2010 at 10:25 PM, Ankur Khurana ankur.kkhur...@gmail.comwrote:

 i will try to elaborate or rewrite tat part

 On Thu, Dec 23, 2010 at 10:25 PM, Ankur Khurana
 ankur.kkhur...@gmail.com wrote:
  wverything i mentioned above can be done in O(n) but sorting part is
  nlogn . so that is what i was saying. can you specify where i was not
  clear ?
 
  On Thu, Dec 23, 2010 at 9:22 PM, Nikhil Agarwal
  nikhil.bhoja...@gmail.com wrote:
  @ankur can you hint your nlogn solution?
 
  On Thu, Dec 23, 2010 at 9:08 PM, Ankur Khurana 
 ankur.kkhur...@gmail.com
  wrote:
 
  it is just like 0/1 knapsack problem with maximum weight of knapsack
  as 40. but in this case that is minimum that we have to calculate.
  calculate marks/time for every element . then try finding the elements
  with max value/time to fulfill the quota of marks. i dont know if this
  can be done in O(n) but it can be certainly done in nlogn. any other
  views ?
 
  On Thu, Dec 23, 2010 at 9:03 PM, Davin dkthar...@googlemail.com
 wrote:
   Thanks for reply. I am looking for O(n) for solution.
  
   Davin
  
   On Dec 23, 8:29 pm, snehal jain learner@gmail.com wrote:
   hint : use dp
  
  
  
  
  
  
  
   On Thu, Dec 23, 2010 at 8:30 PM, Davin dkthar...@googlemail.com
   wrote:
Marks for Questions(1,6): {10,15,20,25,10,20}
Time for Each Questions(1,6) : { 2, 4,3,4, 2,4}
Passing Marks : 40 Out of 100
  
Find Questions with minimum time to pass the exam?
  
On Dec 23, 7:04 pm, juver++ avpostni...@gmail.com wrote:
 Please clarify the problem statement. Provide example.
 From the first view problem seems to be unclear.
  
--
You received this message because you are subscribed to the Google
Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to
   
algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 algogeeks%2bunsubscr...@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 algoge...@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 
 
 
  --
  Thanks  Regards
  Nikhil Agarwal
  Senior Undergraduate
  Computer Science  Engineering,
  National Institute Of Technology, Durgapur,India
  http://tech-nikk.blogspot.com
  http://beta.freshersworld.com/communities/nitd
 
 
  --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To post to this group, send email to algoge...@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Thanks  Regards
Nikhil Agarwal
Senior Undergraduate
Computer Science  Engineering,
National Institute Of Technology, Durgapur,India
http://tech-nikk.blogspot.com
http://beta.freshersworld.com/communities/nitd

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@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] Re: mapping of 2-d arrays

2010-12-23 Thread mohit mittal
how to use hash table
i have a pair (a,b) with which i want to use.
if i use hash function like  a+nb there will be number of clashes.
also , i have tried map stl in some of programs and most of them give
TLE.
So, is there a better way for this or i have to look a different
approach to this.

Thanks
Mohit
On Dec 19, 7:39 pm, juver++ avpostni...@gmail.com wrote:
 Use hash_table, it provides O(1) expected time for searching.

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@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] Re: mapping of 2-d arrays

2010-12-23 Thread juver++
Represent your pair in some radix system. So Hash=(a*Base + b) mod 
SomePrime.

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@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] Simulation algo

2010-12-23 Thread Chi
Ant-Colony-Optimization

- Ursprüngliche Mitteilung -
 Hello, I'm looking for an algorithm of computer science simulation and
 specifically the discrete simulation of any model. Please
 All the best.
 
 -- 
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group. To post to this group, send email to
 algoge...@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 algoge...@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] random function

2010-12-23 Thread Puneet Ginoria
There is a book called The art of computer programming by donald knuth. He
had discussed the random function in great detail.

On Tue, Dec 21, 2010 at 8:06 PM, snehal jain learner@gmail.com wrote:

 How do you write your own random function?

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@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: Array Ranking Problem

2010-12-23 Thread Terence

@Ankur:
It is just 0/1 knapsack problem:
Choose a subset of the questions with sum of scores not exceeding 
(Total Score - Pass Score), while maximize the sum of time of the subset.

So I do not think O(nlogn) greedy algorithm will solve this problem.

On 2010-12-23 23:38, Ankur Khurana wrote:

it is just like 0/1 knapsack problem with maximum weight of knapsack
as 40. but in this case that is minimum that we have to calculate.
calculate marks/time for every element . then try finding the elements
with max value/time to fulfill the quota of marks. i dont know if this
can be done in O(n) but it can be certainly done in nlogn. any other
views ?

On Thu, Dec 23, 2010 at 9:03 PM, Davindkthar...@googlemail.com  wrote:

Thanks for reply. I am looking for O(n) for solution.

Davin

On Dec 23, 8:29 pm, snehal jainlearner@gmail.com  wrote:

hint : use dp







On Thu, Dec 23, 2010 at 8:30 PM, Davindkthar...@googlemail.com  wrote:

Marks for Questions(1,6): {10,15,20,25,10,20}
Time for Each Questions(1,6) : { 2, 4,3,4, 2,4}
Passing Marks : 40 Out of 100
Find Questions with minimum time to pass the exam?
On Dec 23, 7:04 pm, juver++avpostni...@gmail.com  wrote:

Please clarify the problem statement. Provide example.
 From the first view problem seems to be unclear.

--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@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 algoge...@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: Array Ranking Problem

2010-12-23 Thread Ankur Khurana
how will you choose that ?? without sorting . can you please mention
what method you intend to use to achieve that purpose ?

On Fri, Dec 24, 2010 at 8:16 AM, Terence technic@gmail.com wrote:
 @Ankur:
 It is just 0/1 knapsack problem:
    Choose a subset of the questions with sum of scores not exceeding (Total
 Score - Pass Score), while maximize the sum of time of the subset.
 So I do not think O(nlogn) greedy algorithm will solve this problem.

 On 2010-12-23 23:38, Ankur Khurana wrote:

 it is just like 0/1 knapsack problem with maximum weight of knapsack
 as 40. but in this case that is minimum that we have to calculate.
 calculate marks/time for every element . then try finding the elements
 with max value/time to fulfill the quota of marks. i dont know if this
 can be done in O(n) but it can be certainly done in nlogn. any other
 views ?

 On Thu, Dec 23, 2010 at 9:03 PM, Davindkthar...@googlemail.com  wrote:

 Thanks for reply. I am looking for O(n) for solution.

 Davin

 On Dec 23, 8:29 pm, snehal jainlearner@gmail.com  wrote:

 hint : use dp







 On Thu, Dec 23, 2010 at 8:30 PM, Davindkthar...@googlemail.com  wrote:

 Marks for Questions(1,6): {10,15,20,25,10,20}
 Time for Each Questions(1,6) : { 2, 4,3,4, 2,4}
 Passing Marks : 40 Out of 100
 Find Questions with minimum time to pass the exam?
 On Dec 23, 7:04 pm, juver++avpostni...@gmail.com  wrote:

 Please clarify the problem statement. Provide example.
  From the first view problem seems to be unclear.

 --
 You received this message because you are subscribed to the Google
 Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to

 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@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 algoge...@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 algoge...@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.