ThoughtWorks Interview Question for Software Engineer / Developers

• 1
of 1 vote

Comment hidden because of low score. Click to expand.
5
of 5 vote

2,2,4,11....
difference between the n and n-1...follows the sequence 0,2,7...
now 0 can be made as 0*0=0,similar 2 can be made as 1*1+1=2 and 7 can be made as 2*2+2+1=7,following the sequence we get the next difference as 15(3*3+3+2+1)..therefore the next number is 26 in the series.

Comment hidden because of low score. Click to expand.
0

Nice one

Comment hidden because of low score. Click to expand.
0

good one

Comment hidden because of low score. Click to expand.
0

good one

Comment hidden because of low score. Click to expand.
0

Nice way to explain..

Comment hidden because of low score. Click to expand.
0

2 5 8(should be)
0 2 7 X
2 2 4 11 Y

so x should be 15
So y = 11+15 = 26

Comment hidden because of low score. Click to expand.
2

series is
2 2 4 11
difference series is
0 2 7
Again take difference series
2 5
Again
3

so we have 3 now.

add 3 to its above series => 2 5 8
now add this 8 to last term of its above series => 0 2 7 15

Now add this 15 to last term of its above series =>2 2 4 11 26

This is what I mean :)

Comment hidden because of low score. Click to expand.
0

nice explain

Comment hidden because of low score. Click to expand.
0

nice 1

Comment hidden because of low score. Click to expand.
0
of 0 vote

2* 0 + 1 = 2
2* 1 + 2 = 4
4* 2 + 3 = 11
So the next number is
11 * 3 + 4 = 37

Comment hidden because of low score. Click to expand.
1
of 1 vote

2* 0 + 1 = 2?
you are so funny.

Comment hidden because of low score. Click to expand.
0

yes he is right.. (any no)^0=1 :. 2^0=1
:. 2^0+1=2

Comment hidden because of low score. Click to expand.
0

oh sorry it's 2*0 so 2*0+1=2

Comment hidden because of low score. Click to expand.
0

2*0+1=1

Comment hidden because of low score. Click to expand.
0
of 0 vote

2* 0 + 1 = 2 ?

Comment hidden because of low score. Click to expand.
0
of 0 vote

Can you explain a little bit how you got 50,28,67 and 18?

Comment hidden because of low score. Click to expand.
0

2*0+1=1

Comment hidden because of low score. Click to expand.
0
of 0 vote

I think since the series given was short, the purpose of the question was to rather see how many solutions a candidate can come up with, than getting the exact solution they were looking for. It might be a trick question -- just saying.
However, here's how I would do it:
2,2,4,11 -- the difference between consecutive terms is: 0,2,7... which can be looked at as:

2^0 -1 = 0
2^1 -0 = 2
2^3 -1 = 7
so the next difference would be:
2^4 -0 = 16

which gives the next term as 11+16 = 27.
I've never played around with the base x fibonacci, neither heard of it before... but whoever thought about it... RESPECT! ;)

Comment hidden because of low score. Click to expand.
0

u hav taken powers in a series of 0,1,3,4......
hw?????????????????(no regular seq.)

Comment hidden because of low score. Click to expand.
0
of 0 vote

2,2,4,11 the diff bt conseccutive terms is 0,2,7
0^1+1=2
2^2+3=7
7^3+5=348
therfore the next number in the series is 359
2,2,4,7,11,359

Comment hidden because of low score. Click to expand.
0

sry the final series is 2,2,4,11,359

Comment hidden because of low score. Click to expand.
0

pehle toh yeh batao..jayda dimag aa gaya hai kya
kuh bhi bana rahe hooo aur hum man le..

Comment hidden because of low score. Click to expand.
0

@Bala - 0^1=1 and not 1.

Comment hidden because of low score. Click to expand.
0

Sorry, 0^1=0 and not 1.
So, 0^1+1=1 and not 2 as you've written.

Comment hidden because of low score. Click to expand.
0
of 0 vote

@bala will u explain how u chose the powers of 0,2,7

Comment hidden because of low score. Click to expand.
0
of 0 vote

Numbers : 2,2,4,11
Difference : 0,2,7
sequence :
0 = 0^0
2 = 1^1 + 1^0
7 = 2^2 + 2^1 + 2^0
Next number in sequence of differences : 3^3 + 3^2 + 3^1 + 3^0 = 40
Next Number in the original Sequence = 51 (40 + 11)

Comment hidden because of low score. Click to expand.
0

0^0=1 and not 0.

Comment hidden because of low score. Click to expand.
0
of 0 vote

if we take 7 as a base then solution will be
a1=2;
a2=2;
a3=a1+a2;//a3=2+2=4
a4=a1+a2+a3;//a4=2+2+4=8(in decimal)

/*
8=11(in base 7)
*/
a5=a1+a2+a3+a4//a5=2+2+4+11=19(in decimal)
/*
19=25(in base 7)
*/
hence ans may be 25

Comment hidden because of low score. Click to expand.
0

U said a5=a1+a2+a3+a4
a4=8

then
a5=2+2+4+8=16

to the base 7, it will become 22 only na ??

Comment hidden because of low score. Click to expand.
0
of 0 vote

Numbers : 2,2,4,11
Difference : 0,2,7
sequence :
0 = 0*0
2 = 1*1 + 1
7 = 2*+2+1
?=3*3+3+2+1
?=15
Next number in sequence of differences is 15
Next Number in the original Sequence is 26

Comment hidden because of low score. Click to expand.
0
of 0 vote

2, 2, 4, 11
First set of Differences = 0,2,7
Second set of Differences (of the first difference set) = 2,4,.... ie 2*1 = 2, 2*2 = 4, or 2^1 = 2, 2^2 = 4
so assuming the next difference is either of the following -
2*3 = 6, OR 2^3=8
The next number in the Second set of differences would either be 6 or 8

ie 2,4,6 or 2,4,8

Then the next number in the First set of differences would either be -

7+6= 13 OR 7+8 = 15

Last number of original series could either be -

11+13 = 24, or 11+15=26

And finally the series itself might be -

2,2,4,11,24
OR
2,2,4,11,26

Comment hidden because of low score. Click to expand.
0
of 0 vote

Comment hidden because of low score. Click to expand.
0
of 0 vote

2,2,4,11
dist[] = {0,2,7}
solution: dist[n]= (3n^2-5n)/2+1
so the dist[4]=15
so the next num is 26

Comment hidden because of low score. Click to expand.
0
of 0 vote

23

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````g(n) = 2 for n=0;
g(n) = g(n-1) + f(n-1) for n>0
f(n) = n * n + (Sum of i where i runs from 0 to n)

g(0)=2
g(1) = g(1-1) + f(1-1)
= g(0) + f(0)
= 2 + ((0*0)+(0))
= 2
g(2) = g(2-1) + f(2-1)
= g(1) + f(1)
= 2 + ((1*1)+(1+0))
= 2 + (1 + 1)
= 4
g(3) = g(3-1) + f(3-1)
= g(2) + f(2)
= 4 + ((2*2)+(2+1+0))
= 4 + (4 + 3)
= 11
g(4) = g(4-1) + f(4-1)
= g(3) + f(3)
= 11 + ((3*3)+(3+2+1+0))
= 11 + (9 + 6)
= 26``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

1 1 2 15 104 find next no

Comment hidden because of low score. Click to expand.
0
of 0 vote

1. Sort the given numbers in ascending order (Say as 2 , 4 ,6 7)
2. Represent them in binary (0010,0100,0110,0111)
3. Represent all the once in the set as set of number (say 2,3,{2,3},{1,2,3})
4. Take the once from the first set and remove them from all sets and make a new set
a. Take out 2 so new set is {3,{3},{1,3}}
b. Now Take out 3 so new set is {1}
c. Now take out 1 and it is done
So the answer is {0010,0100,0001} i.e 2,4,1

Comment hidden because of low score. Click to expand.
0
of 0 vote

public class TestSeries {

public static void main(String[] args) {
seriesTest1();
}

public static void seriesTest1(){
int arr[]={2,2,4,11,26};
for(int i=0; i<arr.length; i++) {
int j = i * i + getFact(i);
System.out.println(arr[i]+j+"->"+i+"->"+j);
}
}

public static int getFact(int factInput) {
int response = 0;
for(int i=factInput;i>=1; i--) {
response += i;
}
return response;
}
}

Comment hidden because of low score. Click to expand.
0
of 0 vote

There is another way to do it. Answer is 61,

Explanation :

Given number series, 2,2,4,11
Using factorial, leave the first number from the series. and add other numbers in the series with the previous given number.

Example, factorial of 2 is 1,2
Now Leave the the 1st number and add with the previous number. Previous number empty. So,
(1) 2 + 0 (previous number) = 2
(1) 2 + 2 (previous number) = 4
(1) 2 + 3 + 4 + 2 (previous number) = 11
(1) 2 + 3 +... +11 + 4 (previous number) = 61

Comment hidden because of low score. Click to expand.
0
of 0 vote

method of differences taught in elementary schools in enough .

Comment hidden because of low score. Click to expand.
-1
of 1 vote

fibonacci series in base 5
a1=2, a1=2
a3=2+2=4
a4=2+4=6(in base 10)=11(base 5 [5*1+1])

Comment hidden because of low score. Click to expand.
0

can you explain little bit more??

Comment hidden because of low score. Click to expand.
0

take 5 ary system it consists digits 0,1,2,3,4
(for example binary system contains 0,1 and decimal system contains 0 to 9)
lets take fibonacci series with a1=2 and a2=2
then a3= 2+2=4
a4= 2+4= which is six but 5 ary system doesn't contain six as a digit
how can six can be represented using 5 ary system??
11 = 5*1 + 1*1

Comment hidden because of low score. Click to expand.
0

so the next no. is 20?

Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.