[algogeeks] Re: Largest substring with unique characters

2011-07-22 Thread anonymous procrastination
Oh yes you're right. Understood the algo incorrectly. -- 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...@google

[algogeeks] Re: reverse a line.

2011-07-21 Thread anonymous procrastination
Heya, Someone please explain dinesh's approach with an example. I am not able to get the answer. Doing some mistake. -- AP -- 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 un

[algogeeks] Re: Largest substring with unique characters

2011-07-21 Thread anonymous procrastination
@Abhi See every character in the string is read exactly once and hashed. So the complexity is O(n) only. Mistake you're doing is adding n/2 n times, but if you see in your example you have to add it twice only. -- AP -- You received this message because you are subscribed to the Google Groups

[algogeeks] Negative index of array

2011-07-20 Thread anonymous procrastination
Hello, Usually whenever we use index as key to count frequency or other similar algos. The code goes like map[a[i]]++ or something. What if a[i] is negative? Or this kind of thing is for positive numbers only. -- AP -- You received this message because you are subscribed to the Google Groups "A

[algogeeks] Re: Minimum/Maximum Sum path in A Binary Tree

2011-07-13 Thread anonymous procrastination
int maxsum(NODEPTR root) { if(root==NULL) return 0; else { if((maxsum(root->left)>maxsum(root->right)) printf("%d",root->left); else printf("%d",root->right); return MAX(maxsum(root->left),maxsum(root->right))+root->data; } } -- You received this message because you are subscribed to the Google G

[algogeeks] Re: Minimum/Maximum Sum path in A Binary Tree

2011-07-13 Thread anonymous procrastination
int maxsum(NODEPTR root) { if(root==NULL) return 0; else return MAX(maxsum(root->left),maxsum(root->right))+root->data; } This should work. Please comment. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to

[algogeeks] Search node in a binary tree

2011-07-12 Thread anonymous procrastination
Hello, Suppose you have to search a particular node in a binary tree. The code is quite simple. Pick up any traversal and see if any node matches the value. Doubt I have is that how to pull out of the recursive function at the instant node is found. In iterative algos we use a break. Here I can us

[algogeeks] Re: O(n) Time is the problem. ..

2011-07-12 Thread anonymous procrastination
@Dave Can you please explain through example. Suppose the set is {0,1,2,3,5,6} Then how this solution proceeds. I am partially getting the logic you explained but need to see an example. Thanks!! -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" grou

[algogeeks] Re: Random Number Generator

2011-07-06 Thread anonymous procrastination
@surender Yep, I think the same. for(i=0;i<(b-a);i++,a+=rand(0,1)); Watsay? -- 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 algog

[algogeeks] Re: Some adobe interview questions.

2011-07-05 Thread anonymous procrastination
The answer to question 3 can also be 6010 right? so no unique solution? -- 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 algo

[algogeeks] Re: Taking Input

2011-07-02 Thread anonymous procrastination
Hey Thanks,, I got it.. when I press enter after entering the number it takes that as an empty string. -- 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 g

[algogeeks] Re: Taking Input

2011-07-02 Thread anonymous procrastination
#include #include #define INF 9 int main() { int no,i,j=0,num=0; int adj[102][102]={INF}; char neighbours[103],c; scanf("%d",&no); for(i=1;i<=no;i++) { j=0; gets(neighbours); puts(neighbours); } system("PAUSE"); } Can you please tell me why

[algogeeks] Taking Input

2011-07-02 Thread anonymous procrastination
Hello, I came across a problem where the first line of the input specfies a number n. Then next n lines, every line contains a few(no limit) number seperated by spaces. Then I want to find the sm of numbers on each line. eg. INPUT 5 1 4 5 3 1 6 11 23 1 9 8 7 6 7 7 7 Now algorithm offcourse is no

[algogeeks] Re: spoj shlights

2011-06-28 Thread anonymous procrastination
@Kartik Please tell me what logic you're following. @varun This strategy failed. I tried submitting. GBGBBGGBBBGGBBBGBGGBGGBGBGG 101001100011000101101101011 You can try the above case. -- You received this message because you are subscribed to the Google Groups "Algorithm Ge

[algogeeks] Re: strings

2011-06-26 Thread anonymous procrastination
So finally what will be the solution? Harshal's solution doesn't print the characters in the order of appearance in the orignal array as nishant righly pointed out. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send e

[algogeeks] Re: spoj shlights

2011-06-24 Thread anonymous procrastination
Hello, Were you able to figure out the solution? On Jun 23, 3:33 pm, Jitendra singh wrote: > @ kartik sachan > Problem with this code is this- > All GB pairs should be process in one time period > > On 6/23/11, kartik sachan wrote: > > > > > QUESTION LINK IShttp://www.spoj.pl/problems/SHLIGHTS/

[algogeeks] Re: Segmentation fault

2011-06-23 Thread anonymous procrastination
@kartik Still getting SIGSEGV :( Also " a[106]={0};" only works at the time of declaration. I can't use it in the middle of the program. Please correct me if I'm wrong. On Jun 23, 11:43 pm, kartik sachan wrote: > @anoyomous take array size as a[106] > > and dude to intilize array to zer

[algogeeks] Re: Segmentation fault

2011-06-23 Thread anonymous procrastination
Forgot to mention that I'm getting SIGSEV On Jun 23, 10:32 pm, anonymous procrastination wrote: > Hello, > > I tried the question using single array. > Condition on n,d given is 100. So array size goes the same right? > > #include > #include > > int f(int n,

[algogeeks] Re: Segmentation fault

2011-06-23 Thread anonymous procrastination
Hello, I tried the question using single array. Condition on n,d given is 100. So array size goes the same right? #include #include int f(int n,int d); int dp[100]; int main() { int n,d,k,t; while(1) { for(t=0;t<100;t++) dp[t]=0; scanf("%d %d",&n,&d); if(

[algogeeks] Re: Segmentation fault

2011-06-23 Thread anonymous procrastination
Thanks for the clarification :) -- 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 o

[algogeeks] Re: Segmentation fault

2011-06-23 Thread anonymous procrastination
@Harshit Please explain what do you mean by single array? I'm trying to solve the same problem. -- 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,