CARS24
10+ TCS Interview Questions and Answers
Q1. Merge Two Sorted Linked Lists Problem Statement
You are provided with two sorted linked lists. Your task is to merge them into a single sorted linked list and return the head of the combined linked list.
Input:...read more
Merge two sorted linked lists into a single sorted linked list without using additional space.
Create a dummy node to start the merged list
Compare the values of the two linked lists and add the smaller value to the merged list
Move the pointer of the merged list and the pointer of the smaller value list
Continue this process until one of the lists is fully traversed
Append the remaining elements of the other list to the merged list
Q2. Sort 0 1 2 Problem Statement
Given an integer array arr
of size 'N' containing only 0s, 1s, and 2s, write an algorithm to sort the array.
Input:
The first line contains an integer 'T' representing the number of...read more
Sort an array of 0s, 1s, and 2s in linear time complexity.
Use three pointers to keep track of 0s, 1s, and 2s while traversing the array.
Swap elements based on the values encountered to sort the array in-place.
Time complexity should be O(N) and space complexity should be O(1).
To find the fastest 3 horses out of a group with 5 horses racing at a time, we can use a tournament style approach.
Divide the horses into groups of 5 and race them against each other. This will give you the fastest horse in each group.
Take the winners from each group and race them against each other. The top 3 horses in this final race will be the fastest 3 overall.
Keep track of the results and compare the timings to determine the fastest 3 horses.
Output-based questions in JavaScript using browser APIs
Example 1: Write a script that uses the Geolocation API to display the user's current location on a map
Example 2: Create a program that uses the Web Audio API to play a sound when a button is clicked
Example 3: Develop a web page that uses the Canvas API to draw a simple animation
Designing a system to support localization in a mobile app
Use resource files to store localized strings for different languages
Implement a language selection feature for users to choose their preferred language
Utilize localization libraries or frameworks to streamline the process
Consider cultural differences when localizing content, such as date formats and currency symbols
To debug lag on a screen, analyze code, check for memory leaks, optimize rendering, and use profiling tools.
Analyze code to identify any inefficient algorithms or operations causing lag.
Check for memory leaks that could be impacting performance.
Optimize rendering by reducing the number of draw calls, optimizing shaders, and minimizing overdraw.
Use profiling tools like Xcode Instruments or Android Profiler to identify performance bottlenecks.
The app I recently worked on is a social media platform for sharing photos and connecting with friends.
The app follows a client-server architecture, with the client being the mobile app and the server handling data storage and processing.
The client side is built using React Native for cross-platform compatibility.
The server side is implemented using Node.js with a MongoDB database for storing user data and photos.
The app uses RESTful APIs for communication between the client ...read more
The event loop is a mechanism in programming that allows for asynchronous execution of code.
The event loop is a key component in JavaScript's runtime environment, responsible for handling asynchronous operations.
It continuously checks the call stack for any pending tasks and executes them in a non-blocking manner.
The event loop ensures that the program remains responsive by allowing other code to run while waiting for asynchronous tasks to complete.
Example: setTimeout() funct...read more
Q9. Implement a springboot service that intercepts http requests.
Implement a Springboot service to intercept HTTP requests.
Create a Springboot application with necessary dependencies.
Implement a custom interceptor by extending HandlerInterceptorAdapter.
Override preHandle and postHandle methods to intercept requests and responses.
Register the interceptor in the WebMvcConfigurerAdapter configuration class.
Q10. Implementation of LRU cache
LRU cache is a data structure that stores the most recently used items, discarding the least recently used items when full.
Use a doubly linked list to keep track of the order of items based on their usage.
Use a hash map to quickly access items in the cache.
When a new item is accessed, move it to the front of the linked list. If the cache is full, remove the item at the end of the list.
Q11. Implementation of HashMap
HashMap is a data structure that stores key-value pairs and allows for fast retrieval of values based on keys.
HashMap is implemented using an array of linked lists or a balanced tree to handle collisions.
It uses a hash function to map keys to indices in the array.
Example: HashMap
map = new HashMap<>(); map.put("key", 123); int value = map.get("key");
Q12. Implement an immutable class.
An immutable class is a class whose instances cannot be modified after creation.
Use final keyword for class declaration to prevent inheritance
Make all fields private and final to prevent modification
Do not provide setter methods, only getter methods should be used
Interview Process at TCS
Top Software Developer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month