ThoughtWorks Interview Questions
- 0of 0 votes
Answers
- vejon July 16, 2019 in United StatesGiven a number n, make a set of m integers such that the integers lie between [1, n] and the sum of two integers should produce an integer which is in the set. Eg. **Input** n=20, m=5 **Output** [3, 6, 11, 14, 17]
| Report Duplicate | Flag | PURGE
ThoughtWorks Applications Developer - 0of 0 votes
Answer**Game of Bits**
- harshit.knit July 19, 2018 in India
Yale and Xavier are playing a game with numbers. Each round of the game starts with a number given to them by Zita, Yale’s little sister.
The number n is expressed as a binary integer with p bits
For every round, Xavier gets the first move.
The game came consists of moves performed by Yale and Xavier alternately.
The mth move of the game involves performing these operations on the number:
Toggling the mth bit (numbering of bits starts from left) of the number.
Toggling the left adjacent bit of m (if such a bit exists) if it is equal to the mth bit before toggling in step 1; otherwise keep it as is.
Toggling the right adjacent bit of m (if such a bit exists) if it is equal to the mth bit before toggling in step 1; otherwise keep it as is.
This modification of the number goes on until all p moves are made. If the modified number (as a result of all the operations) is
equal (or a distance one away) from the original number, then the person who made the last move wins the round; otherwise the other one wins the round.
**Note:**
The number given to them is converted to its binary form and represented with the help of minimum number of bits.
The numbering for the bits starts from the leftmost bit.
**Constraints**
1<=r<=10^6
1<=n<=10^6, where n is the number given by Zita in any round
**Input Format**
The first line contains a number, r, denoting the number of rounds in the game.
This is followed by r lines, where the ith line contains the number given by Zita for the ith round.
**Output Format**
The output of the problem has r lines, where the ith line contains the winner of ith round as X if Xavier wins ith round or Y if Yale wins the ith round.
**Sample Input**
1
11
**Sample Output**
Y
**Explanation**
11 is represented as 1011 using minimum number of bits in binary.
When Xavier makes the first move, it becomes 0011.
Then Yale makes the 2nd move and it becomes 1111.
After the third move made by Xavier, it becomes 1000.
After the last move by Yale, it becomes 1011 which is 11 in decimal.
The last move was made Yale and the modified number is equal or adjacent to 11,
therefore, Yale wins this round.| Report Duplicate | Flag | PURGE
ThoughtWorks Software Engineer / Developer Algorithm - 3of 3 votes
AnswerBob And GCD
- uppubhai December 11, 2017 in India
Bob has an array A of size N. He doesn't like arrays in which the GCD of all elements is not K. He can perform multiple operations on an array. In each operation, he can either increase or decrease the value of an element by 1.
You have to tell the minimum operation Bob will take to make GCD of all elements in an array equal to KK ?
GCD here is Greatest Common Divisor.
Input Format
The first line contains T, the number of test cases.
For Each Testcase :
The first line contains 2 integers - K and N respectively, separated by a space.
The second line contains N integers, separated by a space, in order of their position in array.
Input Constraints
1≤T≤10
1≤N≤10^6
1≤A[i]≤10^6
1≤K≤10^6
Output Format
For each test case, print minimum number of operations Bob take in a new line.
Sample Input
1
5 3
4 5 6
Ans - 2| Report Duplicate | Flag | PURGE
ThoughtWorks SDE1 - 0of 0 votes
AnswersBasic sales tax is applicable at a rate of 10% on all goods, except books, food, and medical products that are exempt. Import duty is an additional sales tax applicable on all imported goods at a rate of 5%, with no exemptions.
- GUL MD ERSHAD November 05, 2017 in India
When I purchase items I receive a receipt which lists the name of all the items and their price (including tax), finishing with the total cost of the items, and the total amounts of sales taxes paid. The rounding rules for sales tax are that for a tax rate of n%, a shelf price of p contains (np/100 rounded up to the nearest 0.05) amount of sales tax.
Write an application that prints out the receipt details for these shopping baskets.
Input:
1) 1 book at 12.49
2) 1 music CD at 14.99
3) 1 chocolate bar at 0.85| Report Duplicate | Flag | PURGE
ThoughtWorks Senior Software Development Engineer Object Oriented Design - 0of 0 votes
AnswersA list of students and their marks in three subjects are given in the respective order.
- Tywin lannister December 13, 2016 in India
Student1 20 40 65
Student2 35 40 50
Student3 10 55 65
Given n = 2.
Find the name of the students who has got top marks in atleast n subjects.
Output for the above example
student1
student3
since they got top marks in atleast 2 subjects| Report Duplicate | Flag | PURGE
ThoughtWorks Applications Developer Algorithm - 0of 2 votes
Answerpair programming example question with code for thoughworks interview
- rahulgoyal030 August 16, 2016 in India| Report Duplicate | Flag | PURGE
ThoughtWorks Software Developer C++ - 0of 0 votes
AnswersGiven an integer array A of size N. Find the number of increasing sub-sequences of this array with length >= 1 and GCD = 1.
- abhibhagia June 26, 2016 in India
A sub-sequence of an array is obtained by deleting some (or none) elements and maintaining the relative order of the rest of the elements.
Example:-
[1] = 1
[1,2] = 2
[1,2,3] = 5| Report Duplicate | Flag | PURGE
ThoughtWorks Senior Software Development Engineer Dynamic Programming - -1of 1 vote
AnswersOO design for implementing table tennis game between two players? I just want the class diagram not the whole implementation. Only the class/interfaces names will help.
- shridhar.mali657 May 15, 2016 in United States| Report Duplicate | Flag | PURGE
ThoughtWorks Applications Developer Java - 0of 0 votes
AnswersDesign a datastructure which stores employee details Name,PhoneNumber,Addres and the employee details are(all the 3 given above) fetched when the user searches the data structure by Name or phone number
- Rajarathinam Antony December 29, 2015 in India| Report Duplicate | Flag | PURGE
ThoughtWorks SDE1 Algorithm - 0of 0 votes
AnswerTest Question
- rafitoapp1 October 02, 2015 in United States| Report Duplicate | Flag | PURGE
ThoughtWorks Software Engineer Java - 0of 0 votes
AnswersProblem Two: Conference Track Management
- rafitoapp1 October 02, 2015 in United States
You are planning a big programming conference and have received many proposals which have passed the initial screen process but you're having trouble fitting them into the time constraints of the day -- there are so many possibilities! So you write a program to do it for you.
• The conference has multiple tracks each of which has a morning and afternoon session.
• Each session contains multiple talks.
• Morning sessions begin at 9am and must finish by 12 noon, for lunch.
• Afternoon sessions begin at 1pm and must finish in time for the networking event.
• The networking event can start no earlier than 4:00 and no later than 5:00.
• No talk title has numbers in it.
• All talk lengths are either in minutes (not hours) or lightning (5 minutes).
• Presenters will be very punctual; there needs to be no gap between sessions.
Note that depending on how you choose to complete this problem, your solution may give a different ordering or combination of talks into tracks. This is acceptable; you don’t need to exactly duplicate the sample output given here.
Test input:
Writing Fast Tests Against Enterprise Rails 60min
Overdoing it in Python 45min
Lua for the Masses 30min
Ruby Errors from Mismatched Gem Versions 45min
Common Ruby Errors 45min
Rails for Python Developers lightning
Communicating Over Distance 60min
Accounting-Driven Development 45min
Woah 30min
Sit Down and Write 30min
Pair Programming vs Noise 45min
Rails Magic 60min
Ruby on Rails: Why We Should Move On 60min
Clojure Ate Scala (on my project) 45min
Programming in the Boondocks of Seattle 30min
Ruby vs. Clojure for Back-End Development 30min
Ruby on Rails Legacy App Maintenance 60min
A World Without HackerNews 30min
User Interface CSS in Rails Apps 30min
Test output:
Track 1:
09:00AM Writing Fast Tests Against Enterprise Rails 60min
10:00AM Overdoing it in Python 45min
10:45AM Lua for the Masses 30min
11:15AM Ruby Errors from Mismatched Gem Versions 45min
12:00PM Lunch
01:00PM Ruby on Rails: Why We Should Move On 60min
02:00PM Common Ruby Errors 45min
02:45PM Pair Programming vs Noise 45min
03:30PM Programming in the Boondocks of Seattle 30min
04:00PM Ruby vs. Clojure for Back-End Development 30min
04:30PM User Interface CSS in Rails Apps 30min
05:00PM Networking Event
Track 2:
09:00AM Communicating Over Distance 60min
10:00AM Rails Magic 60min
11:00AM Woah 30min
11:30AM Sit Down and Write 30min
12:00PM Lunch
01:00PM Accounting-Driven Development 45min
01:45PM Clojure Ate Scala (on my project) 45min
02:30PM A World Without HackerNews 30min
03:00PM Ruby on Rails Legacy App Maintenance 60min
04:00PM Rails for Python Developers lightning
05:00PM Networking Event| Report Duplicate | Flag | PURGE
ThoughtWorks Software Engineer Java - 1of 1 vote
AnswersTest Question, this is a test question
- rafitoapp1 October 02, 2015 in United States| Report Duplicate | Flag | PURGE
ThoughtWorks Software Engineer Java - 2of 2 votes
Answerswrite a program to perform divison operation of two numbers without using /, %, and modules operatot
- kiran November 15, 2012 in India| Report Duplicate | Flag | PURGE
ThoughtWorks Developer Program Engineer Java - 3of 3 votes
AnswersPrint a character 1000 times without using loop and recursion.
- arun September 07, 2012 in India| Report Duplicate | Flag | PURGE
ThoughtWorks Applications Developer - 0of 0 votes
AnswersGiven list A with 4 integers between 1 and 10, you should come up with list B with three integers such that all the values in list A can be obtained by adding 1 or more values in list B.
- sudhagarsachin July 21, 2012 in India
Example:
input: 2 4 6 7
output:1 2 4
Explanation:
2-2
4-4
6-2+4
7-1+2+4| Report Duplicate | Flag | PURGE
ThoughtWorks Intern Algorithm - 1of 1 vote
Answers2,2,4,11,_
- Amanat Ali October 26, 2010
Find the next number in the series.No more clues.
[I had 1 hour and gave many possible answers like 50,28,67 and 18 but could not convince them. This is such a short series.]| Report Duplicate | Flag | PURGE
ThoughtWorks Software Engineer / Developer - 0of 0 votes
Answersfunc(int* a, int b)
- jamie September 27, 2010
{
while((*a&(1 << b))==0);
}
Why is this piece of code used??| Report Duplicate | Flag | PURGE
ThoughtWorks Consultant C