I think Dave has posted the correct solution, you agree that if the first
string is burned from both ends, it will burn out in exactly 30 minutes,
right?
Also when the first string burns out completely, the second string will
still burn for 30 minutes more, at this time light the other end of
in my compiler,its giving
is rajeev
this is string 1
is ra
On Fri, Jul 8, 2011 at 11:33 AM, rajeev bharshetty rajeevr...@gmail.comwrote:
@Vishal : yes I can use strcpy, But What is the problem with memcpy().
On Fri, Jul 8, 2011 at 11:27 AM, Vishal Thanki
in my compiler,its giving
is rajeev
this is string 1
is ra
On Fri, Jul 8, 2011 at 11:33 AM, rajeev bharshetty rajeevr...@gmail.comwrote:
@Vishal : yes I can use strcpy, But What is the problem with memcpy().
On Fri, Jul 8, 2011 at 11:27 AM, Vishal Thanki
Sort and take window of 2 while traversing,
stop when the elements in the window do not match.The first one will be the
non-repeated assuming only one such number exist in the array.
complexity:o(nlogn)
PS:Another possible solution is =
1. Form a BST.Add extra variable count to the node.
2.while
There are few bugs in your code.
You are going to copy 10 characters in string str1, so the ideal size of str
should be 10+1(for null character).
Now when u used memcpy, then it perfectly copies initial 10 characters in
str1.
You can see it in you current output. But when u use %s for printing
#includestdio.h
#includeerror.h
#includemalloc.h
#includestdlib.h
void swap(void *p1,void *p2,const unsigned size)
{
char *buff=(char*) malloc(size*sizeof(char));
if(!buff)
{
perror(malloc);
exit(11);
}
memcpy(buff,p1,size);
memcpy(p1,p2,size);
memcpy(p2,buff,size);
free(buff);
return;
}
int
generic swap can be written as - #define Swap(T, a, b) {T temp = a; a=b;
b=temp;}
this is working fine in gcc
On Sat, Jul 9, 2011 at 1:45 PM, saurabh singh saurab...@gmail.com wrote:
#includestdio.h
#includeerror.h
#includemalloc.h
#includestdlib.h
void swap(void *p1,void *p2,const
regarding question related to overflow
int ovr_sum(int *sum,int a,int b)
{
*sum=a+b
if(*sum0)
return -1; //overflow
else
return 0; //no problem with the sum (overflow don't occur)
}
On Sat, Jul 9, 2011 at 2:05 PM, John Hayes agressiveha...@gmail.com wrote:
generic swap can
I think Strassen Algorithm is used to multiply Matrices efficiently. Read
Cormen.
--
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/-/qO_1-pri7WIJ.
To post to
I found a good question to try for bit manipulation.Try it... :)
Given an integer x, find out the smallest integer which has same
number of set bits as x and is greater than x.
For example if the input integer is 12 (1100) then your function
should return 17(10001). If the input integer is
find d next:
91,110,134,_
--
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,
6,24,60,120,_
--
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
Solutn:
1101000
Start from rightmost bit-leftmost bit
Find the starting and ending 1’s positions, here 3 and 7
If any 0 bw them… while traversing.. (bitwise r-l).. make it 1 and other
adjacent right ” 1” as “0”. And this is your new no. here 111
If you find no “0” in bw ( eg for
210 for the last one you posted
On Sat, Jul 9, 2011 at 4:33 PM, amit the cool amitthecoo...@gmail.comwrote:
6,24,60,120,_
--
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
Write code to move a set of elements (represented by start and end
indexed) in an array to a given destination location (denoted by
destination index).
For example:
Let say our array is {9, 7, 5, 8, 1, 5, 4, 8, 10, 1}
move_set (array, start = 1, end = 3, destination = 8)
should rearrage the
91,110,134161 i guess
6,24,60,120210
On Sat, Jul 9, 2011 at 5:46 PM, Aman Goyal aman.goya...@gmail.com wrote:
210 for the last one you posted
On Sat, Jul 9, 2011 at 4:33 PM, amit the cool amitthecoo...@gmail.comwrote:
6,24,60,120,_
--
You received this message because you are
This question was asked by ST micro for hiring intern in my college . Here's
the solution :
Let the bottles of alcohol named 0 to 5 then -
No.Binary Value
00 0 0
10 0 1
20 1 0
30 1 1
41 0 0
51 0 1
Mice - a b c
Now make the mice drink alcohol
Hi Geeks
Can anyone please comment on this.
Let me know if the problem description is not clear enough.
Thanks
Gopi
On Jul 9, 5:36 pm, Gopi kodaligopi...@gmail.com wrote:
Write code to move a set of elements (represented by start and end
indexed) in an array to a given destination location
int count1=count2=0;
given number=n;
int m=n; //save in temp variable m
while(m!=0) //count number of bits in given number
{
m=m (m-1);
count1++;
}
m=n; //save in temp variable m
while(count1!=count2) //check no. of bits same or not
{
m=m+1;
@gopi: i didnt really understand what u want to say... what start,end and
destination denotes here??
u said it should start with 1 but in result it is starting with 9...plz
explain ur question again
On Sat, Jul 9, 2011 at 7:21 PM, Gopi kodaligopi...@gmail.com wrote:
Hi Geeks
Can anyone
Reverse elements of set from start to end
Reverse elements of set from end+1 to destination
Reverse elements of set from start to destination
DONE
O(n)
On Sat, Jul 9, 2011 at 7:25 PM, Yogesh Yadav medu...@gmail.com wrote:
@gopi: i didnt really understand what u want to say... what start,end
Hi Yogesh
start and end denote the indexes where the set that is to be moved
starts and ends in the given array.
Destination index denotes the index in the array where the given set
is to be moved. This needs some
rearrangement of the array elements as shown in the example before.
Hope that
@sunny
That's excellent. Thanks Sunny.
On Jul 9, 7:04 pm, sunny agrawal sunny816.i...@gmail.com wrote:
Reverse elements of set from start to end
Reverse elements of set from end+1 to destination
Reverse elements of set from start to destination
DONE
O(n)
On Sat, Jul 9, 2011 at 7:25
91,110,134,..163 ...
6,24,60,120..210
On Sat, Jul 9, 2011 at 6:48 PM, Yogesh Yadav medu...@gmail.com wrote:
91,110,134161 i guess
6,24,60,120210
On Sat, Jul 9, 2011 at 5:46 PM, Aman Goyal aman.goya...@gmail.com wrote:
210 for the last one you posted
On Sat, Jul 9, 2011 at 4:33
@oppilas:
light the first string at both ends and in the middle. So it will burn
completely in 15 min as the fire is advancing in 4 ways irrespective
of the burn rate.
when the first string is completely burnt, light the second string at
both ends to get another 30 min. So, overall 45 min.
On
I had one in my MS apti...
Given a randomly generated 2 d matrix find an element which occurs in all 3
rows...
On Sat, Jul 9, 2011 at 2:47 PM, Nitish Garg nitishgarg1...@gmail.comwrote:
I think Strassen Algorithm is used to multiply Matrices efficiently. Read
Cormen.
--
You received this
@My post: matrix was randomly generated 3X3 matrix...(Not any 2D matrix)
On Sat, Jul 9, 2011 at 9:08 PM, Kunal Patil kp101...@gmail.com wrote:
I had one in my MS apti...
Given a randomly generated 2 d matrix find an element which occurs in all 3
rows...
On Sat, Jul 9, 2011 at 2:47 PM,
code for my *second *solution
http://www.ideone.com/oxDql
http://www.ideone.com/oxDqlPoint out any bugs if you find.
On Sat, Jul 9, 2011 at 12:43 PM, saurabh singh saurab...@gmail.com wrote:
Sort and take window of 2 while traversing,
stop when the elements in the window do not match.The
@saurabh.shouldn't be 5 also be in the outputi think u forgot to
print the root value
On Sat, Jul 9, 2011 at 9:27 PM, saurabh singh saurab...@gmail.com wrote:
code for my *second *solution
http://www.ideone.com/oxDql
http://www.ideone.com/oxDqlPoint out any bugs if you find.
On
Yes, these solution are valid. But for them the burning rate of each string
must be constant.
Each piece of string takes exactly an hour to burn, but the burn rate is not
constant
Can't we have a string which take 45 minutes to burn till half length.
0-L/2. And 15 min from L/2 to L.
On Sat, Jul
int main(){
int i;
float a=5.2;
char *ptr;
ptr=(char *)a;
for(i=0;i=3;i++)
printf(%d ,*ptr++);
}
output:
102 102 -90 64.explain?
--
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.
try to find out the binary representation of float value 5.2
On Sat, Jul 9, 2011 at 10:46 PM, Sangeeta sangeeta15...@gmail.com wrote:
int main(){
int i;
float a=5.2;
char *ptr;
ptr=(char *)a;
for(i=0;i=3;i++)
printf(%d ,*ptr++);
}
output:
102 102 -90 64.explain?
--
You received
Use complete search, add memoization and you have a top-down dynamic
programming solution ready.
- lets say we have division positions in an array cuts[]
- start and end will identify the position of current cut (taken from
cuts[] array)
- initialize memo[][] array to INT_MAX, this is the place
i have an O(nlgn) solution in mind using O(n^2) memory
All the values can be thought as the following matrix
(a0+b0) (a0+b1) (a0+b2).(a0+bn-1)
(a1+b0) (a1+b1) (a1+b2).(a1+bn-1)
.
Can someone please suggest some good links to get questions related to
number series ...
Regards and Thanks
Nikita Jain
On Sat, Jul 9, 2011 at 8:25 PM, vaibhav shukla vaibhav200...@gmail.comwrote:
91,110,134,..163 ...
6,24,60,120..210
On Sat, Jul 9, 2011 at 6:48 PM, Yogesh Yadav
Can someone please suggest some questions to practise number series
questions like
6,24,60,120 find the next no. in the series..
Regards
Nikita
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
#define MESS junk
main()
{
printf(MESS);
}
output is MESS. Why is it happening?
--
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
#includestdio.h
#define MESS junk
void main()
{
printf(MESS);
}
use dis
--
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
no text substitution occurs if the identifier is within the quotes
--
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
refer KRit's clearly mentioned in it
On Sun, Jul 10, 2011 at 12:12 AM, parag khanna khanna.para...@gmail.comwrote:
no text substitution occurs if the identifier is within the quotes
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To
The above posted solution is independent of the burning rate. I am not
counting the minutes using the half burnt string. Instead, the fire is
running and when the whole string is burnt, I am using the time.
Say u light up a string from both ends, then irrespective of burn rate
it should give 30
Sorry, should have done it on paper properly!!
Thanks!
PS: below is the mail which I was about to write thinking that total time
would not be 30 minutes if we burn it from both ends.
Ok
Suppose the length is 60meters.
For 0-L/2 we have burn rate of 2/3m per minute. So, total time L/2/(2/3)=
light the first string at both ends and in the middle. So it will burn
completely in 15 min as the fire is advancing in 4 ways irrespective
of the burn rate.
If we do the similar analysis for 15 min, I think we won't be able to do
so!,
Again if the length is of 60min. For 0-30 min, the burn rate
@Piyush: See http://groups.google.com/group/algogeeks/msg/2b64c4f96fa3598e
for a one-line algorithm.
Dave
On Jul 9, 4:23 am, Piyush Sinha ecstasy.piy...@gmail.com wrote:
I found a good question to try for bit manipulation.Try it... :)
Given an integer x, find out the smallest integer
is it
6,24,60,120,210,336,.. ?
On Sat, Jul 9, 2011 at 4:03 AM, amit the cool amitthecoo...@gmail.comwrote:
6,24,60,120,_
--
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
@Dave..canu u explain ur algo to approach this formula??
On 7/10/11, Dave dave_and_da...@juno.com wrote:
@Piyush: See http://groups.google.com/group/algogeeks/msg/2b64c4f96fa3598e
for a one-line algorithm.
Dave
On Jul 9, 4:23 am, Piyush Sinha ecstasy.piy...@gmail.com wrote:
I found a good
@Piyush: The referenced web page includes a powerpoint presentation
that explains it. Did you read the presentation before asking? If not,
why not?
Dave
On Jul 9, 5:04 pm, Piyush Sinha ecstasy.piy...@gmail.com wrote:
@Dave..canu u explain ur algo to approach this formula??
On 7/10/11, Dave
the string burns in an hour if lit from one end and string burns in 30
min if lit from both ends.
This fact is based on - light up the string from either end it burns
in 60 min.
now heres the solution:
Light up the first string from both ends and the second string from
one end at the same time.
The solution of second puzzle is correct and for the first one I won't
argue now :P.(sorry )
On 7/10/11, Dumanshu duman...@gmail.com wrote:
the string burns in an hour if lit from one end and string burns in 30
min if lit from both ends.
This fact is based on - light up the string from either
6,24,60,120,210,240..
On Sun, Jul 10, 2011 at 3:29 AM, Abhishek Soni ab.abhish...@gmail.comwrote:
is it
6,24,60,120,210,336,.. ?
On Sat, Jul 9, 2011 at 4:03 AM, amit the cool amitthecoo...@gmail.comwrote:
6,24,60,120,_
--
You received this message because you are subscribed to the
(1*1!+2*2!+3*3!+4*4!+10*10!)/11!
.
is there any shortcut methods to solve such problems?
find the odd one out...
13700, 1597, 326, 65, 16 , 6 , 2
and i have no clue to how to solve the second question
--
You received this message because you are subscribed to the Google
hey guys, do you know any website that offers really good aptitude
questions...like interview aptitude questions!!!
i think those are really tough than anything that we find in books
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post
plz give the logic of above series.
--
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
6,24,60,120,210,336..
Explaination:
0 + (6*1) = 6,
6 + (6*3) = 24,
24+ (6*6) = 60,
60+ (6*10) = 120,
120 + (6*15) = 210,
210 + (6*21) = 336,...
On Sat, Jul 9, 2011 at 8:43 PM, aayush jain jain.aayus...@gmail.com wrote:
plz give the logic of above series.
--
You received this message
For the expression, I don't see a simple way. The result is slightly
less than 1.
For the second problem, 1597 is the only odd prime in the list, so it
could be the odd one out.
Dave
On Jul 9, 10:15 pm, Sriganesh Krishnan 2448...@gmail.com wrote:
(1*1!+2*2!+3*3!+4*4!+10*10!)/11!
.
is
@John 5 is the number of inputs that the program will be expecting.Its not
part of the array.
On Sat, Jul 9, 2011 at 9:35 PM, John Hayes agressiveha...@gmail.com wrote:
@saurabh.shouldn't be 5 also be in the outputi think u forgot to
print the root value
On Sat, Jul 9, 2011 at 9:27
If the range is (0,n) then we can solve in O(n) TC and O(1) SC.
int checkconsequtive(int a[],int n){
if(n1)
return 0;
int min=a[0];
int max=a[0];
int i=0;
for(i=1;in;i++)
{
if(a[i]min)
min=a[i];
if(a[i]max)
max=a[i];
}
for the first expression.
summation (i = 1 to i = n ) on i * i ! gives ((n+1)! - 1). May be this may
help in solving the problem.
that is 1*1! = 2! - 1.
1*1! + 2*2! = 3! - 1.
similarly,
1*1! + 2*2! + 3*3! ... + 10*10! = 11! - 1.
On Sun, Jul 10, 2011 at 10:27 AM, Dave dave_and_da...@juno.com
58 matches
Mail list logo