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
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
@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
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
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
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
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
@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
@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
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
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
#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
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
@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
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
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/
@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
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,
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(
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
@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,
21 matches
Mail list logo