
ThoughtWorks


ThoughtWorks Interview Questions and Answers for Freshers
Q1. Add 20% discount code, Implement cashback
To add a 20% discount code and implement cashback in an application.
Create a discount code field in the application where users can enter the code to avail 20% off.
Calculate the discounted price by applying the 20% discount on the original price.
Implement a cashback feature where users receive a certain percentage of the purchase amount back as cashback.
Ensure that the cashback amount is credited to the user's account after the purchase is completed.
Q2. Why python is used for data science
Python is used for data science due to its simplicity, readability, extensive libraries, and community support.
Python is easy to learn and read, making it accessible for beginners and experts alike
Python has a wide range of libraries like NumPy, Pandas, and Scikit-learn for data manipulation and analysis
Python has a strong community support with active forums and resources for data science enthusiasts
Python's versatility allows for integration with other tools and languages c...read more
Q3. Hasmap working on the backend
HashMap is a data structure commonly used in backend development for efficient key-value storage and retrieval.
HashMap is a collection that stores key-value pairs and allows for fast retrieval of values based on keys.
It is commonly used in backend development for caching, session management, and data storage.
Example: HashMap
employeeSalaries = new HashMap<>(); employeeSalaries.put("Alice", 50000); int salary = employeeSalaries.get("Alice");
Q4. Total Unique Paths Problem Statement
You are located at point ‘A’, the top-left corner of an M x N matrix, and your target is point ‘B’, the bottom-right corner of the same matrix. Your task is to calculate the...read more
The problem involves finding the total number of unique paths from the top-left to bottom-right cell of a matrix by moving only right or down.
Use dynamic programming to solve the problem efficiently.
Create a 2D array to store the number of unique paths at each cell.
Initialize the first row and first column with 1 as there is only one way to reach them.
For each cell (i, j), the number of unique paths is the sum of paths from the cell above and the cell to the left.
Return the v...read more
Q5. River Crossing: Help Ninja Cross Over
Ninja stands at the start of a wooden bridge over a river. Some segments of the bridge are damaged. The undamaged segments, marked as 'safe', are listed in an array SAFE
, s...read more
Check if Ninja can cross the river by jumping from one safe segment to another based on given constraints.
Iterate through the 'SAFE' array and check if Ninja can make the required jumps to reach the last safe segment.
Ensure that the next jump is either 'X' - 1, 'X', or 'X' + 1 units from the previous jump.
Return 'true' if Ninja can successfully cross the river, otherwise return 'false'.
Q6. Subtree Node Count Problem
We are provided with a tree containing 'N' nodes, numbered from 0 to N-1. The objective is to determine the total number of nodes within each subtree of the provided tree. Specificall...read more
Given a tree with N nodes, find the number of elements in each subtree rooted at every node.
Traverse the tree using Depth First Search (DFS) to calculate subtree sizes for each node.
Use an array to store subtree sizes for each node, starting with leaf nodes having size 1.
The subtree size of a node is the sum of subtree sizes of its children plus 1 for the node itself.
Q7. Middle of a Linked List
You are given the head node of a singly linked list. Your task is to return a pointer pointing to the middle of the linked list.
If there is an odd number of elements, return the middle ...read more
Return the middle element of a singly linked list, or the one farther from the head if there are even elements.
Traverse the linked list with two pointers, one moving twice as fast as the other
When the fast pointer reaches the end, the slow pointer will be at the middle
Return the element pointed to by the slow pointer
Q8. Check If Linked List Is Palindrome
Given a singly linked list of integers, determine if the linked list is a palindrome.
Explanation:
A linked list is considered a palindrome if it reads the same forwards and b...read more
Check if a given singly linked list of integers is a palindrome or not.
Traverse the linked list to find the middle element using slow and fast pointers.
Reverse the second half of the linked list.
Compare the first half with the reversed second half to determine if it's a palindrome.
More about working at ThoughtWorks




Top HR Questions asked in ThoughtWorks for Freshers
Interview Process at ThoughtWorks for Freshers

Top Interview Questions from Similar Companies








Reviews
Interviews
Salaries
Users/Month

