ThoughtWorks
10+ Recklabs Interview Questions and Answers
Q1. Maximum Sum Subarray Problem Statement
Given an array of integers, find the maximum sum of any contiguous subarray within the array.
Example:
Input:
array = [34, -50, 42, 14, -5, 86]
Output:
137
Explanation:
Th...read more
Find the maximum sum of any contiguous subarray within an array in O(N) time complexity.
Use Kadane's algorithm to find the maximum sum subarray in O(N) time complexity
Initialize two variables: max_sum and current_sum to keep track of the maximum sum subarray
Iterate through the array and update current_sum by adding the current element or starting a new subarray
Update max_sum if current_sum is greater than max_sum
Return max_sum as the maximum sum of any contiguous subarray
Q2. 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
Q3. 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'.
Q4. 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.
Q5. Left View of a Binary Tree
Given a binary tree, your task is to print the left view of the tree. The left view of a binary tree contains the nodes visible when the tree is viewed from the left side.
Input:
The ...read more
The task is to print the left view of a binary tree, which contains the nodes visible when the tree is viewed from the left side.
Traverse the tree in a level order manner and keep track of the leftmost node at each level.
Use a queue to perform level order traversal.
Print the leftmost node at each level to get the left view of the binary tree.
Q6. 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
CHAR is fixed length while VARCHAR2 is variable length in SQL.
CHAR stores fixed length strings, padding with spaces if necessary.
VARCHAR2 stores variable length strings, not padding with spaces.
CHAR is faster for fixed length data, VARCHAR2 is more flexible for varying length data.
Design a Doctor Appointment System with test cases
Create a database to store doctor information, patient information, and appointment details
Implement a user interface for patients to schedule appointments with available doctors
Include features like appointment reminders, cancellation, and rescheduling
Test cases: 1. Schedule appointment successfully 2. Cancel appointment 3. Reschedule appointment
Overloading is having multiple methods in the same class with the same name but different parameters, while overriding is implementing a method in a subclass that is already defined in the superclass.
Overloading involves multiple methods with the same name but different parameters.
Overriding involves implementing a method in a subclass that is already defined in the superclass.
Overloading is resolved at compile time based on the method signature, while overriding is resolved ...read more
There are three types of constructors in C++: default constructor, parameterized constructor, and copy constructor.
Default constructor: Constructor with no parameters.
Parameterized constructor: Constructor with parameters.
Copy constructor: Constructor that initializes an object using another object of the same class.
Example: // Default constructor ClassName() {} // Parameterized constructor ClassName(int x, int y) : x(x), y(y) {} // Copy constructor ClassName(const ClassName&...read more
Q11. Add one API to the existing repository
The API allows users to retrieve weather data based on location.
Create a new endpoint that accepts a location parameter
Use a weather API service to fetch weather data based on the location
Return the weather data in a standardized format, such as JSON
Q12. Add some feature to the project
The feature added to the project is a user authentication system.
Implement a login page with username and password fields.
Create a database table to store user credentials.
Hash and salt passwords for secure storage.
Implement password reset functionality.
Add user roles and permissions for access control.
More about working at ThoughtWorks
Interview Process at Recklabs
Top Software Developer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month