[algogeeks] Re: Bread Butter & Brain
Registration Started.1 Rs at stake.Event starts at 7.30 PM today. -- 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] Re: c-aps
try indiabix.com -- 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] Re: Google Interview Question
Maybe the code has lot of dynamic updations..So for each kind of i/ p there can be different places where the updated value is used. -- 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
@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] need help solving this ACM ICPC prelims problem
Problem D: Numbered Grid A grid of size N rows and M columns is filled with numbers, one in each cell. You start at the centre of the cell at the top-left corner (1,1) and your destination is the centre of the cell at the bottom- right corner(N,M). In each step, you are only allowed to move to the centre of the cell to the right or to the centre of the cell to the bottom. There are many paths you can take to reach your destination from your start - however, every path can be uniquely broken down into a series of straight line-segments joined at right-angles. Each straight line-segment in your path is termed a 'leg' of your path. Your task is to choose a subset of the cells along your path in such a way that the sum of the numbers in the chosen cells is maximized. Your choice of cells must be such that exactly one chosen cell is present on each leg of the path. Note that cells at the intersection of two legs belong to both legs. What is the maximum possible sum you can form? Input Format: The first line contains one integer T, the number of testcases. The first line of each test case contains two space-separated integers N and M. Each of the next N lines contains M space separated integers, denoting cell values. The jth integer in the ith line denotes the value of the cell (i, j). Constraints: 1 <= T <= 10 1 <= N, M <= 100 Numbers in each cell will be between -1 and 1 inclusive. Output Format: For each testcase output a single line containing the maximum sum you can form. Sample Input: 3 2 2 -1 -2 5 -1 3 4 -1 2 -3 -4 -2 -3 5 -2 -1 -1 -2 3 2 2 3 1 5 3 Sample Output: 5 10 6 Explanation: In the first test case, you can first move down and then move right. Your path now has 2 legs and you can choose only the cell containing 5. This is valid as it satisfies the condition that you must choose exactly one cell in each leg (because 5 is a part of both legs). In the second test case, one best path is to walk right, choose 2, go right again and then down to choose 5, go further down and then right to pick up the final 3 (There are also other ways to pick-up the same numbers). In the third test case, the best path is either (down, right) or (right, down). Note that since you can pick-up only one number in each leg you cannot select the '5' in the lower left corner (If you decide to pick-up 5, then you cannot pick up any other number because '5' is shared by both legs. We can do better by selecting both 3s). Time limit: 2 seconds Memory: 64 MB ACM International Collegiate Programming Contest, 2010, Asia- Amritapuri Site -- 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] need help solving this problem
how to find last k digits of n power n 0http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] plz clear my basics
it is very simple..just think that for sufficiently large n...the number of times the loop runs will be depend upon wat ? for example for(int i=0 to n) { for(int =0 to n) { //operations // } } for this the time complexity is O(n^2) because for every i..it runs n times. for lg n it is more likely to form a binary treeit is just 2 often used termfor more ,refer algorithms book by thomas coreman -- 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: Largest Rectangle in a binary Matrix:
Can u explain z-curve?wat data structure can be used .plz provide a link to learn thatthanks 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.
Re: [algogeeks] Re: iTS aLL gOOGLE- iNTERVIEW
for the the third question it is 2 times of catalan number..pl correct me if am wrong -- 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: iTS aLL gOOGLE- iNTERVIEW
here r is numbers we choose usually we have 10 numbers(in case of cell phone) we have 10[0.9] digits so 10^10 numbers are there...correct me if am wrong -- 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: iTS aLL gOOGLE- iNTERVIEW
for the first one it is permutation with repetition because the order matters n = no of digits When you have *n* things to choose from ... you have *n* choices each time! So when choosing *r* of them, the permutations are: *n × n × ... (r times) = nr* correct me if am wrong -- 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: Fwd: [algogeeks] Prim's algorithm using min heap
i couldn't find any link here. -- 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] Prim's algorithm using min heap
Please some one provide link or source code for " Prim's algorithm using min heap" Am having trouble with the implementation -- 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: Bitwise operator - Adobe
#include using namespace std; int main() { int n,temp,ans=1; cin >> n; temp=n/8; temp++; cout << "hi" << temp<<"\n"; while(temp--) { temp=temp<<3; } cout << temp; return 0; } -- 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] Amazon Interview
http://michael.dipperstein.com/rle/index.html Step 1. Set the previous symbol equal to an unmatchable value. Step 2. Read the next symbol from the input stream. Step 3. If the symbol is an EOF exit. Step 4. Write out the current symbol. Step 5. If the symbol is an does not match the previous symbol, set the previous symbol to the current symbol, and go to step 2. Step 6. Read and count additional symbols until a non-matching symbol is found. This is the run length. Step 7. Write out the run length. Step 8. Write out the non-matching symbol. Step 9. Set the previous symbol to the non-matching symbol, and go to step 2. -- 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] help required...
And what if more than one person in that set?...let it be "c". so u must ask ac+1(n-1) questions right? On 9/23/10, Soundar wrote: > isn't it supposed to be only O(n) questions.? > > On 9/23/10, santhosh wrote: >> if the possibilty of a person knowing other any1 based circular linked.. >> ie. >> 1/n.. >> then none becomes celebrity .. so wat to do in tat situation?? >> >> -- >> 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] help required...
isn't it supposed to be only O(n) questions.? On 9/23/10, santhosh wrote: > if the possibilty of a person knowing other any1 based circular linked.. ie. > 1/n.. > then none becomes celebrity .. so wat to do in tat situation?? > > -- > 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: do this: two numbers with min diff
Modeling Expert 's code is greedyit won't work for the test cases in which the optimal answer is does not lie between first two numbers.. On 9/23/10, Srinivas wrote: > can anyone post this answer pls?? > > -- > 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: Finding max for all positions of a moving window
You are correct ...It depends on the max element's index... -- 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: Finding max for all positions of a moving window
1)Sort the first 10 elements (first window) 2)initialise i=1,l=j=10 3)last element is the maximum(l=10) printf(a[l]) 4)i=i+1,j=j+1 if(a[j]>a[l]) then printf(a[j]) l=j 5)else printf(a[l]) 6)if(i==l) repeat from step 1 for worst case it needs 10 sorts Correct if i am wrong -- 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] Array Good One!!!!!!!!!!!!!!!!!!!!!!
array index starting from 0 or 1? in the for loop i <=length isn't it? If no please explain On 9/19/10, Ashish Goel wrote: > this is google question > > take arrays before[] and after > > before[0]=1 > after[length-1]=1; > > for (int i=1; i { > before[i]=a[i]*before[i-1]; > after[length-1-i]=a[length-1-i]*after[length-i]; > } > > now resuly for the asked index is after[index]*before[index] > > > the idea here is that we should not be using division.. > > > additionally, you can improve it if any of the numbers is zero > > > > > > > Best Regards > Ashish Goel > "Think positive and find fuel in failure" > +919985813081 > +919966006652 > > > On Sun, Sep 19, 2010 at 8:18 PM, bittu wrote: > >> >> Given an array of numbers, replace each number with the product of >> all the numbers in the array except the number itself *without* using >> division. >> >> -- >> 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.
Re: [algogeeks] Re: print largest continue subsequent in int array
but the 2 consecutive numbers condition violatesfor -1 we must take only -1 only then we get -1 .If u add 2 negative numbers the answer is less than the 2 elements..So if the array contains ONLY negative numbers the maximum sum can't be achieved for 2 elements.Correct me if i am wrong... On 9/19/10, Krunal Modi wrote: > no > we have to find consecutive numbers such that there some is largest... > here -3 < -1 > > -- > 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] Re: print largest continue subsequent in int array
1)get the numbers 2)Sort the numbers 3)traverse from first number 4)if (a[i]==a[i+1]-1 ) { count++; sum+=(a[i]+a[i+1]) i++; } 5)if (sum>max) { end=count; max=sum; } 6)print down to "count" no of elements from a[end] will this algorithm wok?correct me if i am wrong. -- 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: Yahoo Interview Question for Software Engineer/Developer about Algorithms
Even if u are connected to that person via some another friend it'll show the shortest chain by which you are connected to that person..So DFS will be optimum i guessWhy do you think it wouldn't be optimum.? -- 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: num to words
for n=190 there it'll give segmentation error.but it contains only 19 elements you have to do like x=n/100 then one[x] -- 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: num to words
we can use map map we have to manipulate 4 type of maps.. 1)1-9 2) 10 - 20 3)21-99 3)then hundreds,thousands correct me if i am wrong -- 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 Question
>From first linked list set flag value in each traversal of node..then start from second linked list suppose if flag value is already set that is the intersection point correct me if i am wrong -- 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: Given an array, find out if there exists a pair of nos. that adds up to a sum 'x'
#include #include #include using namespace std; int main() { int n,a[30],temp[30],x; cin >> n; memset(temp,0,sizeof(temp)); for(int i=0;i> a[i]; cin >> x; temp[x-a[0]]=1; for(int i=1;ihttp://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: I want improve my algorithm??
www.spoj.pl www.topcoder.com/tc www.codechef.com Solve problems from these sites.. -- 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: how we can access 2nd element of an struct
can you explain?thanks 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: how we can access 2nd element of an struct
It is giving me error."invalid cast from type ‘main()::node’ to type ‘char*" -- 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: Spoj problem (dynamic programming)
post the problem link -- 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: How to print path of a node
try DFS -- 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: how we can access 2nd element of an struct
u didn't give any name for the structure so it'll give error.correct me if i am wrong -- 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 (Array yet again!)
Finding the longest increasing sub sequence and comparing with the original array ...will this method work? -- 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: evaluate expression
Pl provide some test cases or more like examples -- 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.