Add office photos
Engaged Employer

CARS24

3.6
based on 3.6k Reviews
Video summary
Filter interviews by

10+ TCS Interview Questions and Answers

Updated 10 Jul 2024
Popular Designations

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

Ans.

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

View 1 answer

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
Ans.

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).

Add your answer
Q3. You need to find the fastest 3 horses out of a group, given that you can only race 5 horses at a time. How would you approach this problem?
Ans.

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.

Add your answer
Q4. Can you provide examples of output-based questions in JavaScript that utilize browser APIs?
Ans.

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

Add your answer
Discover TCS interview dos and don'ts from real experiences
Q5. How would you design a system to support localization in a mobile app?
Ans.

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

Add your answer
Q6. How do you debug the root cause of lag on a screen?
Ans.

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.

Add your answer
Are these interview questions helpful?
Q7. Can you explain the architecture of the app you have recently worked on?
Ans.

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

Add your answer
Q8. What is the event loop and what is its significance?
Ans.

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

Add your answer
Share interview questions and help millions of jobseekers 🌟

Q9. Implement a springboot service that intercepts http requests.

Ans.

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.

Add your answer

Q10. Implementation of LRU cache

Ans.

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.

Add your answer

Q11. Implementation of HashMap

Ans.

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");

Add your answer

Q12. Implement an immutable class.

Ans.

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

Add your answer
Contribute & help others!
Write a review
Share interview
Contribute salary
Add office photos

Interview Process at TCS

based on 3 interviews
Interview experience
3.0
Average
View more
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top Software Developer Interview Questions from Similar Companies

3.6
 • 122 Interview Questions
3.6
 • 19 Interview Questions
3.8
 • 16 Interview Questions
4.7
 • 15 Interview Questions
3.8
 • 11 Interview Questions
3.5
 • 10 Interview Questions
View all
Share an Interview
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
70 Lakh+

Reviews

5 Lakh+

Interviews

4 Crore+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter