Re: [algogeeks] Microsoft written test question

2012-09-06 Thread shashi kant
that what i mentioned finding original BST or a correcting the BST property
...
my method will only maintains the BST property...

-- 
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] Number of arrangements

2012-09-06 Thread Navin Kumar
@tendua: Answer will be 6C3 x 3! .

For example: If 5 letters are given then you can get only 10 combination of
different letter = 5C3

ABC
ABD
ABE
BCD
BCE
CDE
ACD
ACE
ADE
BDE

now each of these can be arranged in 3! ways. So final answer will be : 120

On Fri, Sep 7, 2012 at 1:11 AM, tendua  wrote:

>
> http://placement.freshersworld.com/placement-papers/Persistent-/Placement-Paper-Whole-Testpaper-1884
> question no. 4 in 5th section
>
>
> On Thursday, September 6, 2012 4:40:08 PM UTC+5:30, isandeep wrote:
>
>> Can you send the link to the question.
>>
>> On Thu, Sep 6, 2012 at 4:35 PM, tendua  wrote:
>>
>>> from the six elements, we could choose any three in C(6,3) ways which is
>>> 20 and then permute all the three elements so it will be multiplied by 3!
>>> which is 6. Hence, 20*6 = 120. We still have to multiply it by 3 to get 360
>>> but I'm not getting why?
>>>
>>>
>>> On Thursday, September 6, 2012 3:54:11 PM UTC+5:30, atul007 wrote:
>>>
 seems output should be 20.

 On Thu, Sep 6, 2012 at 3:26 PM, tendua  wrote:

> from the set {a,b,c,d,e,f} find number of arrangements for 3 alphabets
> with no data repeated?
> Answer given is 360. but how?
>
> --
> 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/*
> *ms**g/algogeeks/-/E4U2XlfkvgMJ
> .
> To post to this group, send email to algo...@googlegroups.com.
> To unsubscribe from this group, send email to algogeeks+...@**
> 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 view this discussion on the web visit https://groups.google.com/d/**
>>> msg/algogeeks/-/VMO1othQRcQJ
>>> .
>>>
>>> To post to this group, send email to algo...@googlegroups.com.
>>> To unsubscribe from this group, send email to algogeeks+...@**
>>> 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 view this discussion on the web visit
> https://groups.google.com/d/msg/algogeeks/-/z6KbH2i6BP0J.
>
> 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] Enter in the loop challenge

2012-09-06 Thread Shashank Jain
@vijay nice thought.

but actually the while loop has changed because of addition of label in it.

another possible answer could be   write a cout << "hello"; statement above
the main

but the problem  given was  enter into the loop without changing the loop.

On Wed, Sep 5, 2012 at 10:09 PM, SHOBHIT GUPTA
wrote:

> also the keywords like int , long etc cannot be included in macro
>
> On Wed, Sep 5, 2012 at 7:01 PM, Shashank Jain wrote:
>
>> thanks that was a really nice explanation
>>
>> shashank
>>
>>
>> On Wed, Sep 5, 2012 at 6:48 PM, Bala  wrote:
>>
>>> Source: http://gcc.gnu.org/onlinedocs/cpp/Macros.html
>>>
>>> You may define any valid identifier as a macro, even if it is a C
>>> keyword. The preprocessor does not know anything about keywords. This
>>> can be useful if you wish to hide a keyword such as const from an
>>> older compiler that does not understand it. However, the preprocessor
>>> operator defined (see Defined) can never be defined as a macro, and
>>> C++'s named operators (see C++ Named Operators) cannot be macros when
>>> you are compiling C++.
>>>
>>>
>>> Cheers,
>>> -Bala
>>>
>>> “Judge nothing, be happy.
>>>  Forgive everything, be happier.
>>>  Love everything, be happiest.”
>>> ~Sri Chinmoy
>>>
>>>
>>> On Wed, Sep 5, 2012 at 8:12 AM, Shashank Jain 
>>> wrote:
>>> > can you plz explain how it happens ...as valid macro names  must not
>>> be key
>>> > words.
>>> >
>>> >
>>> > On Wed, Sep 5, 2012 at 6:24 PM, Shashank Jain <
>>> shashank29j...@gmail.com>
>>> > wrote:
>>> >>
>>> >>
>>> >> it works
>>> >> thanks for your reply
>>> >>
>>> >>
>>> >>
>>> >> On Wed, Sep 5, 2012 at 6:19 PM, Bala  wrote:
>>> >>>
>>> >>> #define while(x) while(1)
>>> >>>
>>> >>> Cheers,
>>> >>> -Bala
>>> >>>
>>> >>>
>>> >>>
>>> >>> On Wed, Sep 5, 2012 at 7:45 AM, Shashank Jain <
>>> shashank29j...@gmail.com>
>>> >>> wrote:
>>> >>> > Here is a question...and i am badly stuck at it
>>> >>> >
>>> >>> > how would you get into the loop
>>> >>> >
>>> >>> > int main()
>>> >>> > {
>>> >>> >
>>> >>> >  while ( 0)
>>> >>> >  {
>>> >>> >printf("hello");
>>> >>> >
>>> >>> >  }
>>> >>> > return 0;
>>> >>> > }
>>> >>> >
>>> >>> >
>>> >>> > You cannot change the while loop and its condition and you have to
>>> >>> > print
>>> >>> > "hello"
>>> >>> >
>>> >>> > --
>>> >>> > 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.
>>
>
>  --
> 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?

Re: [algogeeks] Print all possible valid set of given numer

2012-09-06 Thread atul anand
correct...

On 9/6/12, bharat b  wrote:
> no need to look for 3 or above digits ..
>
> On Thu, Aug 23, 2012 at 11:11 AM, atul anand
> wrote:
>
>> divide number into digit form and save to arr[]
>> input=1234
>> formed arr[]={1,2,3,4};
>> print elements for arr[];
>>
>> now make set of 2 , 3, 4,
>> i.e
>> when i=2;
>> we get
>> *12*,3,4
>> 1,*23*,4
>> 1,2,*34*
>>
>> i=3
>> *123*,4
>> 1,*234*
>> i=4
>> *1234*
>>
>> On Wed, Aug 22, 2012 at 6:34 PM, zeroByZero 
>> wrote:
>>
>>> A set will be call valid if all number can be represent as a alphabet
>>> (ie
>>> number should be less than or equal to 26) .
>>> Example :
>>> given number is 1234 then
>>> 1) {1,2,3,4} - valid ans
>>> 2){12,3,4} - Valid
>>> 3){1,23,4} -Valid
>>> 4){1,2,34} -not valid
>>> 5){123,4} - not valid
>>> 6){1234} not valid
>>> So for given number print All valid SET.
>>>
>>> --
>>> 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/-/9GDKbM5jYp4J.
>>> 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.



Re: [algogeeks] Number of arrangements

2012-09-06 Thread tendua
http://placement.freshersworld.com/placement-papers/Persistent-/Placement-Paper-Whole-Testpaper-1884
question no. 4 in 5th section

On Thursday, September 6, 2012 4:40:08 PM UTC+5:30, isandeep wrote:
>
> Can you send the link to the question.
>
> On Thu, Sep 6, 2012 at 4:35 PM, tendua  >wrote:
>
>> from the six elements, we could choose any three in C(6,3) ways which is 
>> 20 and then permute all the three elements so it will be multiplied by 3! 
>> which is 6. Hence, 20*6 = 120. We still have to multiply it by 3 to get 360 
>> but I'm not getting why?
>>
>>
>> On Thursday, September 6, 2012 3:54:11 PM UTC+5:30, atul007 wrote:
>>
>>> seems output should be 20.
>>>
>>> On Thu, Sep 6, 2012 at 3:26 PM, tendua  wrote:
>>>
 from the set {a,b,c,d,e,f} find number of arrangements for 3 alphabets 
 with no data repeated?
 Answer given is 360. but how? 

 -- 
 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/-/E4U2XlfkvgMJ
 .
 To post to this group, send email to algo...@googlegroups.com.
 To unsubscribe from this group, send email to algogeeks+...@**
 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 view this discussion on the web visit 
>> https://groups.google.com/d/msg/algogeeks/-/VMO1othQRcQJ.
>>
>> To post to this group, send email to algo...@googlegroups.com
>> .
>> To unsubscribe from this group, send email to 
>> algogeeks+...@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 view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/z6KbH2i6BP0J.
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] Number of arrangements

2012-09-06 Thread Rathish Kannan
120 arrangements...

--  RK :)


On Thu, Sep 6, 2012 at 6:00 PM, Navin Kumar wrote:

> @tendua: answer would be 6C3. Read about combination definition.
>
>
> On Thu, Sep 6, 2012 at 5:05 PM, atul anand wrote:
>
>> question says *3 alphabets with no data repeated* ...you no need of
>> doing 3! permutation.
>> eg 123 and 321 are same
>>
>>
>> On Thu, Sep 6, 2012 at 4:35 PM, tendua  wrote:
>>
>>> from the six elements, we could choose any three in C(6,3) ways which is
>>> 20 and then permute all the three elements so it will be multiplied by 3!
>>> which is 6. Hence, 20*6 = 120. We still have to multiply it by 3 to get 360
>>> but I'm not getting why?
>>>
>>>
>>> On Thursday, September 6, 2012 3:54:11 PM UTC+5:30, atul007 wrote:
>>>
 seems output should be 20.

 On Thu, Sep 6, 2012 at 3:26 PM, tendua  wrote:

> from the set {a,b,c,d,e,f} find number of arrangements for 3 alphabets
> with no data repeated?
> Answer given is 360. but how?
>
> --
> 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/-/E4U2XlfkvgMJ
> .
> To post to this group, send email to algo...@googlegroups.com.
> To unsubscribe from this group, send email to algogeeks+...@**
> 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 view this discussion on the web visit
>>> https://groups.google.com/d/msg/algogeeks/-/VMO1othQRcQJ.
>>>
>>> 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.



Re: [algogeeks] Microsoft written test question

2012-09-06 Thread Rahul Kumar Patle
@shashi: once we have two pointer where anomalies exist, we can exchange
their data value to obtain original BST...

On Wed, Sep 5, 2012 at 12:38 PM, shashi kant  wrote:

> Is it required only to retain the BST property ??  or to retain the
> original BST (tree)
>
>
>
>
> *Shashi Kant *
> ***"Think positive and find fuel in failure"*
> http://thinkndoawesome.blogspot.com/
> *System/Software Engineer*
> *Hewlett-Packard India Software Operations.
> *
>
>
>
> On Tue, Sep 4, 2012 at 1:56 PM, Rahul Kumar Patle <
> patlerahulku...@gmail.com> wrote:
>
>> @atul: correctly caught...
>> here you have to notice that if u get only one violation not second
>> violation ill the last... then sure the violation is created because of
>> swapping of previous and current of first violation...
>> so when you got first violation and put first marker on previous time put
>> second marker on current...
>> suppose and the last if you don't get the second violation then 2nd
>> marker will the current node of first violation...
>> as in your case when we got first violation at node prev = 20 and current
>> = 10.. mark first point at 20 and second pointer at 10.. at the last the
>> 2nd pointer does not get change...
>> i have checked this with other test cases.. this case is coming only when
>> previous and current are the consecutive nodes(parent and its direct child)
>> and one of the node is leaf node...
>>
>> On Tue, Sep 4, 2012 at 1:22 AM, atul anand wrote:
>>
>>> i guess i missed this part of bharat post :-
>>> /*
>>> If we don't get the violation for the second time .. means both are
>>> side-by-side elements .. swap them ..
>>> */
>>> i was saying the same.so it will work.
>>>
>>>
>>> On 9/4/12, atul anand  wrote:
>>> > @rahul : Here are the boundary cases need to be taken care of :-
>>> > suppose given BST is the following :-
>>> >
>>> > root=allocate(70);
>>> > root->right=allocate(75);
>>> > root->left=allocate(50);
>>> > root->left->left=allocate(20);
>>> > root->left->left->right=allocate(25);
>>> > root->left->left->left=allocate(10);
>>> > root->left->right=allocate(60);
>>> > root->left->right->right=allocate(65);
>>> > root->left->right->left=allocate(55);
>>> >
>>> > now suppose node(20) and node(10) get swapped
>>> >
>>> > inorder of given tree is :-
>>> > 20 10 25 50 55 60 65 70 75
>>> >
>>> > now first violation is at node(20)
>>> > but you wont get second voilation...because rest is in inc order.
>>> >
>>> > yes , it can be done by taking care of root of that first violation.
>>> >
>>> >
>>> > On 9/3/12, Rahul Kumar Patle  wrote:
>>> >> @bharat: +1
>>> >> i have tried some test cases.. working finely.. @anyone pls verify??
>>> >>
>>> >> On Mon, Sep 3, 2012 at 11:58 AM, bharat b
>>> >> wrote:
>>> >>
>>> >>> while doing in-order traversal, we have to check if(prev > current)
>>> -->
>>> >>> then mark prev element for swapping in the first time violation..
>>> >>> if it happens for the second time..then mark current element for
>>> >>> swapping.
>>> >>> swap both ..
>>> >>>
>>> >>> If we don't get the violation for the second time .. means both are
>>> >>> side-by-side elements .. swap them ..
>>> >>>
>>> >>> Hope works .. If I miss any case .. correct me
>>> >>> thanks,
>>> >>>
>>> >>>
>>> >>> On Sun, Sep 2, 2012 at 7:45 PM, Rahul Kumar Patle <
>>> >>> patlerahulku...@gmail.com> wrote:
>>> >>>
>>>  @navin: can u explain ur algorithms in words pls..
>>> 
>>>  On Sun, Sep 2, 2012 at 5:53 PM, Navin Kumar
>>>  wrote:
>>> 
>>> > void correctBST(struct node *root)
>>> > {
>>> >   int flag =0;
>>> >   static struct node *temp1, *temp2, *temp3, *prev;
>>> >   static int found;
>>> >
>>> >   if(found) return;
>>> >
>>> >   if(root) {
>>> >   correctBST(root->left);
>>> >   if(!temp1 && prev && root->data < prev->data) {
>>> >   temp1 = prev;
>>> >   temp2 = root;
>>> >   swap(&(temp1->data), &(temp2->data));
>>> >   flag = 1;
>>> >   prev = temp1;
>>> >   }
>>> >   else if(!temp3 && prev && root->data < prev->data) {
>>> >   temp3 = root;
>>> >   swap(&(temp1->data), &(temp2->data));
>>> >   swap(&(temp1->data), &(temp3->data));
>>> >   found = 1;
>>> >   return;
>>> >   }
>>> >   if(!flag)
>>> >  prev = root;
>>> >   correctBST(root->right);
>>> >   }
>>> > }
>>> >
>>> > On Sun, Sep 2, 2012 at 4:02 PM, Rahul Kumar Patle <
>>> > patlerahulku...@gmail.com> wrote:
>>> >
>>> >> help to solve the following..
>>> >> Question: Two of the nodes of a BST are swapped. Correct the BST
>>> >> (taken
>>> >> from GeekforGeeks 
>>> 2nd
>>> >> online test 3rd question)
>>> >>
>>> >>
>>> >>
>>> >>
>>> >> --
>>> >> Thanks and Regards:
>>> >> Rahul Kumar
>>> >> Patle<
>>> http

Re: [algogeeks] array problem

2012-09-06 Thread Arman Kamal
It will be even easier with BIT (Binary Indexed Tree), if you know how to
use it.

-- 
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] Enter in the loop challenge

2012-09-06 Thread SHOBHIT GUPTA
also the keywords like int , long etc cannot be included in macro

On Wed, Sep 5, 2012 at 7:01 PM, Shashank Jain wrote:

> thanks that was a really nice explanation
>
> shashank
>
>
> On Wed, Sep 5, 2012 at 6:48 PM, Bala  wrote:
>
>> Source: http://gcc.gnu.org/onlinedocs/cpp/Macros.html
>>
>> You may define any valid identifier as a macro, even if it is a C
>> keyword. The preprocessor does not know anything about keywords. This
>> can be useful if you wish to hide a keyword such as const from an
>> older compiler that does not understand it. However, the preprocessor
>> operator defined (see Defined) can never be defined as a macro, and
>> C++'s named operators (see C++ Named Operators) cannot be macros when
>> you are compiling C++.
>>
>>
>> Cheers,
>> -Bala
>>
>> “Judge nothing, be happy.
>>  Forgive everything, be happier.
>>  Love everything, be happiest.”
>> ~Sri Chinmoy
>>
>>
>> On Wed, Sep 5, 2012 at 8:12 AM, Shashank Jain 
>> wrote:
>> > can you plz explain how it happens ...as valid macro names  must not be
>> key
>> > words.
>> >
>> >
>> > On Wed, Sep 5, 2012 at 6:24 PM, Shashank Jain > >
>> > wrote:
>> >>
>> >>
>> >> it works
>> >> thanks for your reply
>> >>
>> >>
>> >>
>> >> On Wed, Sep 5, 2012 at 6:19 PM, Bala  wrote:
>> >>>
>> >>> #define while(x) while(1)
>> >>>
>> >>> Cheers,
>> >>> -Bala
>> >>>
>> >>>
>> >>>
>> >>> On Wed, Sep 5, 2012 at 7:45 AM, Shashank Jain <
>> shashank29j...@gmail.com>
>> >>> wrote:
>> >>> > Here is a question...and i am badly stuck at it
>> >>> >
>> >>> > how would you get into the loop
>> >>> >
>> >>> > int main()
>> >>> > {
>> >>> >
>> >>> >  while ( 0)
>> >>> >  {
>> >>> >printf("hello");
>> >>> >
>> >>> >  }
>> >>> > return 0;
>> >>> > }
>> >>> >
>> >>> >
>> >>> > You cannot change the while loop and its condition and you have to
>> >>> > print
>> >>> > "hello"
>> >>> >
>> >>> > --
>> >>> > 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.
>

-- 
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] Number of arrangements

2012-09-06 Thread vaibhav shukla
I guess 720 must be the ans.
Its like forming three-letter words out of given 6 without repetition.
In that case = 6p3 * 3!

On Thu, Sep 6, 2012 at 3:53 PM, atul anand  wrote:

> seems output should be 20.
>
>
> On Thu, Sep 6, 2012 at 3:26 PM, tendua  wrote:
>
>> from the set {a,b,c,d,e,f} find number of arrangements for 3 alphabets
>> with no data repeated?
>> Answer given is 360. but how?
>>
>> --
>> 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/-/E4U2XlfkvgMJ.
>> 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.
>



-- 
best wishes!!
 Vaibhav

-- 
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] Enter in the loop challenge

2012-09-06 Thread vijay jain
You can put a label in while condition and then use goto label to print
hello.

#include
int main()
{
  goto vijay;
 while ( 0)
 {
 vijay:  printf("hello");
 }
return 0;
}
Am i right..please reply..

On Wed, Sep 5, 2012 at 6:15 PM, Shashank Jain wrote:

> Here is a question...and i am badly stuck at it
>
> how would you get into the loop
>
> int main()
> {
>
>  while ( 0)
>  {
>printf("hello");
>
>  }
> return 0;
> }
>
>
> You cannot change the while loop and its condition and you have to print
> "hello"
>
> --
> 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] Number of arrangements

2012-09-06 Thread vaibhav shukla
cmon.. what logic are you applying ? its the arrangements.. so basically
this is what will happen
there are three places  __,__,__  first can be filled in 6 ways,Since
repetition is not allowed,second place could be filled in 5 ways and third
in 4
So total arrangements so far  = 6*5*4 = 120 . Now these three letters can
change their position in 3! ways making total arrangements to be = 120*3! =
720 .

On Thu, Sep 6, 2012 at 4:35 PM, tendua  wrote:

> from the six elements, we could choose any three in C(6,3) ways which is
> 20 and then permute all the three elements so it will be multiplied by 3!
> which is 6. Hence, 20*6 = 120. We still have to multiply it by 3 to get 360
> but I'm not getting why?
>
>
> On Thursday, September 6, 2012 3:54:11 PM UTC+5:30, atul007 wrote:
>
>> seems output should be 20.
>>
>> On Thu, Sep 6, 2012 at 3:26 PM, tendua  wrote:
>>
>>> from the set {a,b,c,d,e,f} find number of arrangements for 3 alphabets
>>> with no data repeated?
>>> Answer given is 360. but how?
>>>
>>> --
>>> 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/-/E4U2XlfkvgMJ
>>> .
>>> To post to this group, send email to algo...@googlegroups.com.
>>> To unsubscribe from this group, send email to algogeeks+...@**
>>> 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 view this discussion on the web visit
> https://groups.google.com/d/msg/algogeeks/-/VMO1othQRcQJ.
>
> 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.
>



-- 
best wishes!!
 Vaibhav

-- 
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] Number of arrangements

2012-09-06 Thread Sandeep Gupta
Can you send the link to the question.

On Thu, Sep 6, 2012 at 4:35 PM, tendua  wrote:

> from the six elements, we could choose any three in C(6,3) ways which is
> 20 and then permute all the three elements so it will be multiplied by 3!
> which is 6. Hence, 20*6 = 120. We still have to multiply it by 3 to get 360
> but I'm not getting why?
>
>
> On Thursday, September 6, 2012 3:54:11 PM UTC+5:30, atul007 wrote:
>
>> seems output should be 20.
>>
>> On Thu, Sep 6, 2012 at 3:26 PM, tendua  wrote:
>>
>>> from the set {a,b,c,d,e,f} find number of arrangements for 3 alphabets
>>> with no data repeated?
>>> Answer given is 360. but how?
>>>
>>> --
>>> 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/-/E4U2XlfkvgMJ
>>> .
>>> To post to this group, send email to algo...@googlegroups.com.
>>> To unsubscribe from this group, send email to algogeeks+...@**
>>> 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 view this discussion on the web visit
> https://groups.google.com/d/msg/algogeeks/-/VMO1othQRcQJ.
>
> 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] Enter in the loop challenge

2012-09-06 Thread Varun

>
> This one's clever!

-- 
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/-/DVlEUy17gMgJ.
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] hi

2012-09-06 Thread mind boggler
can somebody share their interview exp wid RBS, gurgaon?

-- 
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] Print all possible valid set of given numer

2012-09-06 Thread bharat b
no need to look for 3 or above digits ..

On Thu, Aug 23, 2012 at 11:11 AM, atul anand wrote:

> divide number into digit form and save to arr[]
> input=1234
> formed arr[]={1,2,3,4};
> print elements for arr[];
>
> now make set of 2 , 3, 4,
> i.e
> when i=2;
> we get
> *12*,3,4
> 1,*23*,4
> 1,2,*34*
>
> i=3
> *123*,4
> 1,*234*
> i=4
> *1234*
>
> On Wed, Aug 22, 2012 at 6:34 PM, zeroByZero  wrote:
>
>> A set will be call valid if all number can be represent as a alphabet (ie
>> number should be less than or equal to 26) .
>> Example :
>> given number is 1234 then
>> 1) {1,2,3,4} - valid ans
>> 2){12,3,4} - Valid
>> 3){1,23,4} -Valid
>> 4){1,2,34} -not valid
>> 5){123,4} - not valid
>> 6){1234} not valid
>> So for given number print All valid SET.
>>
>> --
>> 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/-/9GDKbM5jYp4J.
>> 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.



[algogeeks] RBS interview experience

2012-09-06 Thread mind boggler
hi
can anyone plz share their interview experience at RBS,gurgaon
no. of rounds and nature of rounds
what areas to focus on
also tell if there was any group activity
and finally no. of selected students from one's clg...
thanks

-- 
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: array problem

2012-09-06 Thread sunny
use the concept of segment tree+lazy propagation

On Saturday, August 25, 2012 2:39:54 AM UTC+5:30, wentworth miller wrote:
>
> Hi,
> You are given N numbers. You have to perform two kinds of operations:
> U x y - x-th number becomes equal to y.
> Q x y - calculate the sum of distinct numbers from x-th to y-th. It means 
> that the sum for the set {1, 2, 3, 2, 7} will be equal to 13 (1+2+3+7).
>
> 1<=N<=5 and 
> t is the number of test cases where   1<=t<=10
>
> all numbers fit in the 32 bit integer range...
>
> suggest some solution..
>
> here is my solution
> but it is giving wrong answer fo some unknown test case...plz suggest me 
> the test case where i am getting wrong answer
>
>
> #include
> #include
> int main()
> {
> int list[5],i,n,j,sum,k,l;char c;long t;
> scanf 
> ("%d",&n);
> for(i=0;i {
> scanf 
> ("%d",&list[i]);
> }
> scanf 
> ("%ld",&t);
> t=2*t;
> while(t)
> {
> sum=0;
> scanf 
> ("%c",&c);
> fflush(stdin);
> scanf 
> ("%d  
>   %d",&k,&l);   
> if(c=='Q')
> {
> for(i=k-1;i {
> for(j=i+1;j {
>if(list[i]==list[j])
>   break;
>else if((j==l-1) &&(list[i]!=list[j]))
>{
>   sum=sum+list[i];
>
>}
> }
>  }
>
>  printf 
> ("%d\n",sum+list[l-1]);
>  }
>  if(c=='U')
>  {
>  list[k-1]=l;
>
>  }
>  t--;
> }
> return 0;   
> }
>
>
>
>

-- 
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/-/wLRpyiBiLuoJ.
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] Number of arrangements

2012-09-06 Thread Navin Kumar
@tendua: answer would be 6C3. Read about combination definition.

On Thu, Sep 6, 2012 at 5:05 PM, atul anand  wrote:

> question says *3 alphabets with no data repeated* ...you no need of doing
> 3! permutation.
> eg 123 and 321 are same
>
>
> On Thu, Sep 6, 2012 at 4:35 PM, tendua  wrote:
>
>> from the six elements, we could choose any three in C(6,3) ways which is
>> 20 and then permute all the three elements so it will be multiplied by 3!
>> which is 6. Hence, 20*6 = 120. We still have to multiply it by 3 to get 360
>> but I'm not getting why?
>>
>>
>> On Thursday, September 6, 2012 3:54:11 PM UTC+5:30, atul007 wrote:
>>
>>> seems output should be 20.
>>>
>>> On Thu, Sep 6, 2012 at 3:26 PM, tendua  wrote:
>>>
 from the set {a,b,c,d,e,f} find number of arrangements for 3 alphabets
 with no data repeated?
 Answer given is 360. but how?

 --
 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/-/E4U2XlfkvgMJ
 .
 To post to this group, send email to algo...@googlegroups.com.
 To unsubscribe from this group, send email to algogeeks+...@**
 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 view this discussion on the web visit
>> https://groups.google.com/d/msg/algogeeks/-/VMO1othQRcQJ.
>>
>> 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.



Re: [algogeeks] array problem

2012-09-06 Thread srikanth reddy malipatel
post the logic not the code!
BTW this  problem can be done using segment trees.

http://community.topcoder.com/tc?module=Static&d1=tutorials&d2=lowestCommonAncestor


On Thu, Sep 6, 2012 at 4:51 PM, bharat b wrote:

> Its better to write an O(n) solution for this problem as the # test cases
> are very high and #elements are also very huge..
> use visited array for distinct numbers ... space--O(n).. time--O(n)
>
>
> On Sat, Aug 25, 2012 at 2:39 AM, michael miller <
> wentworth.miller6...@gmail.com> wrote:
>
>> Hi,
>> You are given N numbers. You have to perform two kinds of operations:
>> U x y - x-th number becomes equal to y.
>> Q x y - calculate the sum of distinct numbers from x-th to y-th. It means
>> that the sum for the set {1, 2, 3, 2, 7} will be equal to 13 (1+2+3+7).
>>
>> 1<=N<=5 and
>> t is the number of test cases where   1<=t<=10
>>
>> all numbers fit in the 32 bit integer range...
>>
>> suggest some solution..
>>
>> here is my solution
>> but it is giving wrong answer fo some unknown test case...plz suggest me
>> the test case where i am getting wrong answer
>>
>>
>> #include
>> #include
>> int main()
>> {
>> int list[5],i,n,j,sum,k,l;char c;long t;
>> scanf 
>> ("%d",&n);
>> for(i=0;i> {
>> scanf 
>> ("%d",&list[i]);
>>
>> }
>> scanf 
>> ("%ld",&t);
>>
>> t=2*t;
>> while(t)
>> {
>> sum=0;
>> scanf 
>> ("%c",&c);
>>
>> fflush(stdin);
>> scanf 
>> ("%d 
>>%d",&k,&l);
>>
>> if(c=='Q')
>> {
>> for(i=k-1;i> {
>> for(j=i+1;j> {
>>if(list[i]==list[j])
>>   break;
>>else if((j==l-1) &&(list[i]!=list[j]))
>>
>>{
>>   sum=sum+list[i];
>>
>>}
>> }
>>  }
>>
>>  printf 
>> ("%d\n",sum+list[l-1]);
>>
>>  }
>>  if(c=='U')
>>  {
>>  list[k-1]=l;
>>
>>  }
>>  t--;
>> }
>> 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 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.
>



-- 
Srikanth Reddy M
(M.Sc Tech.) Information Systems
BITS-PILANI

-- 
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] Number of arrangements

2012-09-06 Thread atul anand
question says *3 alphabets with no data repeated* ...you no need of doing
3! permutation.
eg 123 and 321 are same

On Thu, Sep 6, 2012 at 4:35 PM, tendua  wrote:

> from the six elements, we could choose any three in C(6,3) ways which is
> 20 and then permute all the three elements so it will be multiplied by 3!
> which is 6. Hence, 20*6 = 120. We still have to multiply it by 3 to get 360
> but I'm not getting why?
>
>
> On Thursday, September 6, 2012 3:54:11 PM UTC+5:30, atul007 wrote:
>
>> seems output should be 20.
>>
>> On Thu, Sep 6, 2012 at 3:26 PM, tendua  wrote:
>>
>>> from the set {a,b,c,d,e,f} find number of arrangements for 3 alphabets
>>> with no data repeated?
>>> Answer given is 360. but how?
>>>
>>> --
>>> 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/-/E4U2XlfkvgMJ
>>> .
>>> To post to this group, send email to algo...@googlegroups.com.
>>> To unsubscribe from this group, send email to algogeeks+...@**
>>> 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 view this discussion on the web visit
> https://groups.google.com/d/msg/algogeeks/-/VMO1othQRcQJ.
>
> 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] array problem

2012-09-06 Thread bharat b
Its better to write an O(n) solution for this problem as the # test cases
are very high and #elements are also very huge..
use visited array for distinct numbers ... space--O(n).. time--O(n)

On Sat, Aug 25, 2012 at 2:39 AM, michael miller <
wentworth.miller6...@gmail.com> wrote:

> Hi,
> You are given N numbers. You have to perform two kinds of operations:
> U x y - x-th number becomes equal to y.
> Q x y - calculate the sum of distinct numbers from x-th to y-th. It means
> that the sum for the set {1, 2, 3, 2, 7} will be equal to 13 (1+2+3+7).
>
> 1<=N<=5 and
> t is the number of test cases where   1<=t<=10
>
> all numbers fit in the 32 bit integer range...
>
> suggest some solution..
>
> here is my solution
> but it is giving wrong answer fo some unknown test case...plz suggest me
> the test case where i am getting wrong answer
>
>
> #include
> #include
> int main()
> {
> int list[5],i,n,j,sum,k,l;char c;long t;
> scanf 
> ("%d",&n);
> for(i=0;i {
> scanf 
> ("%d",&list[i]);
> }
> scanf 
> ("%ld",&t);
> t=2*t;
> while(t)
> {
> sum=0;
> scanf 
> ("%c",&c);
> fflush(stdin);
> scanf 
> ("%d  
>   %d",&k,&l);
> if(c=='Q')
> {
> for(i=k-1;i {
> for(j=i+1;j {
>if(list[i]==list[j])
>   break;
>else if((j==l-1) &&(list[i]!=list[j]))
>{
>   sum=sum+list[i];
>
>}
> }
>  }
>
>  printf 
> ("%d\n",sum+list[l-1]);
>  }
>  if(c=='U')
>  {
>  list[k-1]=l;
>
>  }
>  t--;
> }
> 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 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] Number of arrangements

2012-09-06 Thread tendua
from the six elements, we could choose any three in C(6,3) ways which is 20 
and then permute all the three elements so it will be multiplied by 3! 
which is 6. Hence, 20*6 = 120. We still have to multiply it by 3 to get 360 
but I'm not getting why?

On Thursday, September 6, 2012 3:54:11 PM UTC+5:30, atul007 wrote:
>
> seems output should be 20.
>
> On Thu, Sep 6, 2012 at 3:26 PM, tendua  >wrote:
>
>> from the set {a,b,c,d,e,f} find number of arrangements for 3 alphabets 
>> with no data repeated?
>> Answer given is 360. but how? 
>>
>> -- 
>> 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/-/E4U2XlfkvgMJ.
>> To post to this group, send email to algo...@googlegroups.com
>> .
>> To unsubscribe from this group, send email to 
>> algogeeks+...@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 view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/VMO1othQRcQJ.
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] Number of arrangements

2012-09-06 Thread atul anand
seems output should be 20.

On Thu, Sep 6, 2012 at 3:26 PM, tendua  wrote:

> from the set {a,b,c,d,e,f} find number of arrangements for 3 alphabets
> with no data repeated?
> Answer given is 360. but how?
>
> --
> 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/-/E4U2XlfkvgMJ.
> 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] Number of arrangements

2012-09-06 Thread tendua
from the set {a,b,c,d,e,f} find number of arrangements for 3 alphabets with 
no data repeated?
Answer given is 360. but how?

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