shreyans
BAN USER- 0of 0 votes
AnswersThat you are given 4 identical tablets. Of which 2 are for cold and 2 for headache. 100mg each. All the tablets look the same. You have a patient and you have to provide him with the medicine. You must give him one tablet for cold and one for headache. But you do not know which one is for cold and which one for the headache. So how will you give it to him. If he has more than 100mg of a specific medicine he'll die.
- shreyans in United States| Report Duplicate | Flag | PURGE
ZS Associates Developer Program Engineer Ideas - 0of 0 votes
AnswersThere are four people who want to cross a bridge; they all begin on the same side. You have 17 minutes to get them all across to the other side. It is night, and they have one flashlight. A maximum of two people can cross the bridge at one time. Any party that crosses, either one or two people, must have the flashlight with them. The flashlight must be walked back and forth; it cannot be thrown, for example. Person 1 takes 1 minute to cross the bridge, person 2 takes 2 minutes, person 3 takes 5 minutes, and person 4 takes 10 minutes. A pair must walk together at the rate of the slower person’s pace. For example, if person 1 and person 4 walk across first, 10 minutes have elapsed when they get to the other side of the bridge. If person 4 returns the flashlight, a total of 20 minutes have passed and you have failed the mission.
- shreyans in United States
please giv a sol...| Report Duplicate | Flag | PURGE
Dude its only applicable for three words..
for a case like:
{def, fgha, efga , abcde, fkl }
then its gets arraged as ::
{def, fgha, abcde, efga, fkl } /// fails and else part runs and
//
replaces l+1 with nth
efga , fgha, abcde, def, fka. // process and gives result //which is wrong
1. test no. of cantacts that can be saved
2. test size of profile photo that can be attached .
size of a message that can be send in a tym
test how much time it can work continuously..
test ratio of fails in sending message..
test for responce time after a message is send
test respnce time by sending continuously to a cntact..
how long chat can it save
dear the answer is correct
but it goes lke...i will xplain it with ur xmple..
comp 1. 1st and 2 nd elent 2nd is smaller
comp. 2 smaller with 3rd ....3rd is more smaller i.e 1
so order till now is 1st then 2nd then 3rd
even if 3rd was larger than 2nd we would be havng our 3rd largest element......
we dnt need to consider order f 1st nd hence some of our comparisons are saved
comp 3. smalller with 4 if 4 is smaller it comes to 3rd position else position of 3 that is going to be place of median remains same..
comp. 4 smaller with 5th elemnt ...nd if 5 th is smaller
then means would be 3rd element
minimus 4 comparison aswer
#include<stdio.h>
#include<conio.h>
#include<math.h>
int a[30],count=0;
int place(int pos)
{
int i;
for(i=1;i<pos;i++)
{
if((a[i]==a[pos])||((abs(a[i]-a[pos])==abs(i-pos))))
return 0;
}
return 1;
}
void print_sol(int n)
{
int i,j;
count++;
printf("\n\nSolution #%d:\n",count);
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
if(a[i]==j)
printf("Q\t");
else
printf("*\t");
}
printf("\n");
}
}
void queen(int n)
{
int k=1;
a[k]=0;
while(k!=0)
{
a[k]=a[k]+1;
while((a[k]<=n)&&!place(k))
a[k]++;
if(a[k]<=n)
{
if(k==n)
print_sol(n);
else
{
k++;
a[k]=0;
}
}
else
k--;
}
}
void main()
{
int i,n;
clrscr();
printf("Enter the number of Queens\n");
scanf("%d",&n);
queen(n);
printf("\nTotal solutions=%d",count);
getch();
}
can be calculated in two parse..
for the first parse.....we find the no. of elements
if even first n/2 int are inserted in stack
and for next n/2 they are popped if same element is encountered else not a palindrom
for odd n/2 floor are inserted
and n+1/2 element is ignored and same as for even popping starts for same element
else not a palindrom
@: nitin
in 1 st iteration all odds are removed
so 1 , 3, 5, 7...... are not to be considered
for any no of itertions they would have been removed
now after 1 st iteration we have
2 4 6 8 10 12 14 16
in 2nd we remove every 3 rd no.
means.... 2(1+3.x) where x varies from 0 to some no.
like 2 8 14 ....
now after 2 nd iteration left are
4 6 10 12 16 18 22 24 28.....
in 3 rd we remove every 4 th element
so we remove 4(1+3x) where x from 0 to some no.
eg...4 16 28.....
..
is that clearn now for every nth iteration
2(n-1)(1+3x) where x from 0 to some no.
all odd no. will be removed in 1st iteration
...
let say for a give no. X=45465454154654 i.e even and itr be the iteration upto which we have to say it will be removed or not
then
for (n=1;n<=itr;n++)
{
for(z=1;X>2n(1+3z);z++)
{
if X%(2.n(1+3z))==0;
print"removed in"+ nth +"iteration";
}
}
hey friends
what if we construct a binary search tree it would have a time complexity of log(no. of elements=k.N) + its inorder traversal O(k.N)
where N is no. of elements in a stream...
becoz if we use heap for such large data set our programme will give heep Exception..
here in yr solution ...we have to check for each node and also move the entire circular path till negative sum comes...
.
.
time complexity is high(n^2)
.
.
.if we simply deal with problem like take the distance between 2 points and fuel ratio....the max. would be the most optimal point...
.
.
.
of cource your answer is a genuine one but could thiss work??
d. adding a argument with default value would need a recompilation for sure...
- shreyans December 07, 2014c. make destructor virtual -- I don't remember any such concept in java..
java -- has finalize methord to do last time clean up and GC