Two sticks and matchbox, measure exactly 45 minutes by burning these sticks


Question: You have two sticks and matchbox. Each stick takes exactly an hour to burn from one end to the other. The sticks are not identical and do not burn at a constant rate. As a result, two equal lengths of the stick would not necessarily burn in the same amount of time.  How would you measure exactly 45 minutes by burning these sticks?

Answer: This puzzle used to be asked in Wall Street interviews long time ago. It is very rare for this question to be asked now but it is a very good question to help you think a little outside the normal thought process.

The answer is really simple. Since the sticks do not burn at a constant rate, we can not use the length of the stick as any sort of measurement of time. If we light a stick, it takes 60 minutes to burn completely. What if we light the stick from both sides? It will take exactly half the original time, i.e. 30 minutes to burn completely.

0 minutes – Light stick 1 on both sides and stick 2 on one side.
30 minutes – Stick 1 will be burnt out. Light the other end of stick 2.
45 minutes – Stick 2 will be burnt out.

If you have any interesting questions, feel free to email them to support@goforexam.in
Read more ...

Aptitude Question - what is the proportion of boys to girls in the country?


Question: In a country where everyone wants a boy, each family continues having babies till they have a boy. After some time, what is the proportion of boys to girls in the country? (Assuming probability of having a boy or a girl is the same)

Answer: This is a very simple probability question in a software interview. This question might be a little old to be ever asked again but it is a good warm up.

Assume there are C number of couples so there would be C boys. The number of girls can be calculated by the following method.
Number of girls = 0*(Probability of 0 girls) + 1*(Probability of 1 girl) + 2*(Probability of 2 girls) + …
Number of girls = 0*(C*1/2) + 1*(C*1/2*1/2) + 2*(C*1/2*1/2*1/2) + …
Number of girls = 0 + C/4 + 2*C/8 + 3*C/16 + …
Number of girls = C
(using mathematical formulas; it becomes apparent if you just sum up the first 4-5 terms)

Thus the proportion of boys to girls is 1 : 1.
Read more ...

Finding the sub-array with the largest sum.


Question: You are given an array with integers (both positive and negative) in any random order. Find the sub-array with the largest sum.

Answer: This is an all-time favorite software interview question. The best way to solve this puzzle is to use Kadane’s algorithm which runs in O(n) time. The idea is to keep scanning through the array and calculating the maximum sub-array that ends at every position. The sub-array will either contain a range of numbers if the array has intermixed positive and negative values, or it will contain the least negative value if the array has only negative values. Here’s some code to illustrate.
 
void maxSumSubArray( int *array, int len, int *start, int *end, int *maxSum )
{
    int maxSumSoFar = -2147483648;
    int curSum = 0;
    int a = b = s = i = 0;
    for( i = 0; i < len; i++ ) {
        curSum += array[i];
        if ( curSum > maxSumSoFar ) {
            maxSumSoFar = curSum;
            a = s;
            b = i;
        }
        if( curSum < 0 ) {
            curSum = 0;
            s = i + 1;
        }
    }
    *start = a;
    *end = b;
    *maxSum = maxSumSoFar;
}
 
Think you have a better solution? We'd love to read your comments!
Read more ...

Reverse a Linked-list. Write code in C.


Question : Reverse a Linked-list. Write code in C.

Answer: There are multiple ways to go about this. Let’s first look at a recursive solution.
 
Node * reverse( Node * ptr , Node * previous)
{
    Node * temp;
    if(ptr->next == NULL) {
        ptr->next = previous;
        return ptr;
    } else {
        temp = reverse(ptr->next, ptr);
        ptr->next = previous;
        return temp;
    }
}
reversedHead = reverse(head, NULL);

Now for a non-recursive solution.

 
Node * reverse( Node * ptr )
{
    Node * temp;
    Node * previous = NULL;
    while(ptr != NULL) {
        temp = ptr->next;
        ptr->next = previous;
        previous = ptr;
        ptr = temp;
    }
    return previous;
}
 

If anyone has any modifications or a better methods, please post it up. Comments are always welcome.
Read more ...

TCS Aptitude test, Placement Questions with Solution



1) If log 0.317=0.3332 and log 0.318=0.3364 then find log 0.319 ?
Sol: log 0.317=0.3332 and log 0.318=0.3364, then
log 0.319=log0.318+(log0.318-log0.317) = 0.3396

2) A box of 150 packets consists of 1kg packets and 2kg packets. Total weight of box is 264kg. How many 2kg packets are there ?
Sol: x= 2 kg Packs
y= 1 kg packs
x + y = 150     .......... Eqn 1
2x + y = 264   .......... Eqn 2
Solve the Simultaneous equation; x = 114
so, y = 36
ANS :  Number of 2 kg Packs = 114.

3) My flight takes of at 2am from a place at 18N 10E and landed 10 Hrs later at a place with coordinates 36N70W. What is the local time when my plane landed?

Options: a)6:00 am b) 6:40am c) 7:40 d) 7:00 e) 8:00
Sol: The destination place is 80 degree west to the starting place. Hence the time difference between these two places is 5 hour 20 min. (=24hr*80/360).
When the flight landed, the time at the starting place is 12 noon (2 AM + 10 hours).
Hence, the time at the destination place is 12 noon - 5:20 hours = 6: 40 AM

4) A plane moves from 9°N40°E to 9°N40°W. If the plane starts at 10 am and takes 8 hours to reach the destination, find the local arrival time ?
Sol: Since it is moving from east to west longitide we need to add both
ie,40+40=80
multiply the ans by 4
=>80*4=320min
convert this min to hours ie, 5hrs 33min
It takes 8hrs totally . So 8-5hr 30 min=2hr 30min
So the ans is 10am+2hr 30 min
=>ans is 12:30 it will reach

5) The size of the bucket is N kb. The bucket fills at the rate of 0.1 kb per millisecond. A programmer sends a program to receiver. There it waits for 10 milliseconds. And response will be back to programmer in 20 milliseconds. How much time the program takes to get a response back to the programmer, after it is sent? answer with explanation.
Sol: see it doesn't matter that wat the time is being taken to fill the bucket.after reaching program it waits there for 10ms and back to the programmer in 20 ms.then total time to get the response is 20ms +10 ms=30ms...it's so simple....

6) A fisherman's day is rated as good if he catches 9 fishes, fair if 7 fishes and bad if 5 fishes. He catches 53 fishes in a week n had all good, fair n bad days in the week. So how many good, fair n bad days did the fisher man had in the week
Ans: 4 good, 1 fair n 2 bad days
Sol: Go to river catch fish
4*9=36
7*1=7
2*5=10
36+7+10=53...
take what is given 53
good days means --- 9 fishes so 53/9=4(remainder=17)  if u assume 5 then there is no chance for bad days.
fair days means ----- 7 fishes so remaining 17 --- 17/7=1(remainder=10) if u assume 2 then there is no chance for bad days.
bad days means -------5 fishes so remaining 10---10/5=2days.
  Ans: 4 good, 1 fair, 2bad. ==== total 7 days.

x+y+z=7--------- eq1
9*x+7*y+5*z=53 -------eq2
multiply eq 1 by 9,
9*x+9*y+9*z=35 -------------eq3
from eq2 and eq3
2*y+4*z=10-----eq4
since all x,y and z are integer i sud put a integer value of y such that z sud be integer in eq 4 .....and ther will be two value y=1 or 3 then z = 2 or 1 from eq 4

for first  y=1,z=2 then from eq1 x= 4
so 9*4+1*7+2*5=53.... satisfied
now for second y=3 z=1 then from eq1 x=3
so 9*3+3*7+1*5=53 ......satisfied
so finally there are two solution of this question
(x,y,z)=(4,1,2) and (3,3,1)...

7) Y catches 5 times more fishes than X. If total number of fishes caught by X and Y is 42, then number of fishes caught by X?
Sol: Let no. of fish x catches=p
no. caught by y =r
r=5p.
r+p=42
then p=7,r=35

8) Three companies are working independently and receiving the savings 20%, 30%, 40%. If the companies work combinely, what will be their net savings?
Sol: suppose total income is 100
so amount x is getting is 80
y is 70
z =60
total=210

but total money is 300
300-210=90
so they are getting 90 rs less
90 is 30% of 300 so they r getting 30% discount

9) The ratio of incomes of C and D is 3:4.the ratio of their expenditures is 4:5. Find the ratio of their savings if the savings of C is one fourths of his income?
Sol: incomes:3:4
expenditures:4:5
3x-4y=1/4(3x)
12x-16y=3x
9x=16y
y=9x/16
(3x-4(9x/16))/((4x-5(9x/16)))
ans:12/19


10) If G(0) = -1 G(1)= 1 and G(N)=G(N-1) - G(N-2) then what is the value of G(6)?
Ans: -1
bcoz g(2)=g(1)-g(0)=1+1=2
g(3)=1
g(4)=-1
g(5)=-2
g(6)=-1
Read more ...

Upcoming Exams Dates and Details- Government, Bank..

Upcoming Notifications:

Banks :

Recruitment Board Post name
SBI Clerks
SBI Associate Bank PO

UPSC :

Post Date Exam Name Last Date
17/05/2014 Civil Services (Preliminary) Exam 2014 16/06/2014
17/05/2014 Indian Forest Services (Preliminary) Exam 2014 16/06/2014
21/06/2014 NDA & NA Exam (II) 2014 21/07/2014
19/07/2014 CDS Exam(II) 2014 18/08/2014

SSC :

Post Date Exam Name Last Date
24/05/2014 Stenographer (Gr C&D) Exam 2014 20/06/2014
19/07/2014 Combined Higher Secondary (10+2) Exam 2014 15/08/2014
09/08/2014 Junior Translator (CSOLS)/Jr Hindi Translator Exam 2014 05/09/2014

Indian Army :
Notification Date Name of The Course Tentative Course of Commencement
.


TNPSC :
Post Date Exam Name Tentative Vacancies
1st Week of March 2014  (To be Notified Later) Group VI Examination (Forest Apprentice) 26
3rd Week of March 2014  (To be Notified Later) Assistant Works Manager 4
2nd Week of April 2014  (To be Notified Later) Combined Civil Services Exam-II (Interview Posts) [Group-II Services] .
4th Week of April 2014 Statistical Inspector 2
2nd Week of May 2014 Group VII-B Service Exam (Executive Officer Gr-III) .
1st Week of June 2014 Group-IA (Asst Conservator of Forests) .
2nd Week of June 2014 Group VIII Service Exam (Executive Officer Gr-IV) .
3rd Week of June 2014 Research Assistant 4
1st Week of July 2014 Group IV Services Examination .
1st Week of August 2014 Combined Civil Services-III Exam (Group III-A) .
2nd Week of August 2014 Assistant Geologist 1
2nd Week of August 2014 Social Case Work Expert 3
1st Week of September 2014 Combined Civil Services Exam-IB (Group-IB Service) .
2nd Week of September 2014 Chemist 3
1st Week of October 2014 Assistant Tester 2
1st Week of November 2014 General Foreman & Technical Assistant 5
1st Week of December 2014 Combined Civil Services Examination (Group-I) .
Read more ...

Like and Share With Your Friends