Add office photos
Engaged Employer

Paytm

3.3
based on 7.1k Reviews
Filter interviews by

30+ TCS Interview Questions and Answers

Updated 5 Feb 2024
Popular Designations
Q1. Sub Sort

You are given an integer array ‘ARR’. You have to find the length of the shortest contiguous subarray such that, if you sort this subarray in ascending order, then the whole array will be sorted in asce...read more

View 4 more answers
Q2. Sort 0 1 2

You have been given an integer array/list(ARR) of size 'N'. It only contains 0s, 1s and 2s. Write a solution to sort this array/list.

Note :
Try to solve the problem in 'Single Scan'. ' Single Scan' r...read more
View 3 more answers
Q3. Minimum Characters For Palindrome

Given a string STR of length N. The task is to return the count of minimum characters to be added at front to make the string a palindrome.

For example, for the given string “de...read more

View 2 more answers
Q4. LCA In A BST

You are given a binary search tree of integers with N nodes. You are also given references to two nodes P and Q from this BST.

Your task is to find the lowest common ancestor(LCA) of these two given...read more

View 3 more answers
Discover TCS interview dos and don'ts from real experiences
Q5. Ceil from BST

Ninja is given a binary search tree and an integer. Now he is given a particular key in the tree and returns its ceil value. Can you help Ninja solve the problem?

Note:
Ceil of an integer is the cl...read more
Add your answer
Q6. Rotate matrix by 90 degrees

You are given a square matrix of non-negative integers 'MATRIX'. Your task is to rotate that array by 90 degrees in an anti-clockwise direction using constant extra space.

For example...read more

View 2 more answers
Are these interview questions helpful?
Q7. Subtree of Another Tree

Given two binary trees T and S, check whether tree S has exactly the same structure and node values with a subtree of T, i.e., check if tree S is a subtree of the tree T.

A subtree of a t...read more

View 3 more answers
Q8. Count Ways To Reach The N-th Stairs

You have been given a number of stairs. Initially, you are at the 0th stair, and you need to reach the Nth stair. Each time you can either climb one step or two steps. You are...read more

Ans.

The task is to find the number of distinct ways to climb from the 0th step to the Nth step, where each time you can climb either one step or two steps.

  • Use dynamic programming to solve this problem

  • Create an array to store the number of ways to reach each step

  • Initialize the first two elements of the array as 1 and 2

  • For each subsequent step, the number of ways to reach that step is the sum of the number of ways to reach the previous two steps

  • Return the number of ways to reach th...read more

View 4 more answers
Share interview questions and help millions of jobseekers 🌟
Q9. Factorial of a Number

Write a program to find the factorial of a number.

Factorial of n is:

n! = n * (n-1) * (n-2) * (n-3)....* 1

Output the factorial of 'n'. If it does not exist, output 'Error'.

Input format :...read more
View 2 more answers
Q10. Next Greater Element

For a given array/list of integers of size N, print the Next Greater Element(NGE) for every element. The Next Greater Element for an element X is the first element on the right side of X in ...read more

View 2 more answers
Q11. Check If Two Nodes Are Cousins

You are given an arbitrary binary tree consisting of N nodes, where each node is associated with a certain value, and two node values, a and b, you need to check if these nodes are...read more

View 2 more answers
Q12. Trapping Rain Water

You have been given a long type array/list 'ARR' of size 'N'. It represents an elevation map wherein 'ARR[i]' denotes the elevation of the 'ith' bar. Print the total amount of rainwater that ...read more

View 3 more answers
Q13. Rotting Oranges

You have been given a grid containing some oranges. Each cell of this grid has one of the three integers values:

  • Value 0 - representing an empty cell.
  • Value 1 - representing a fresh orange.
  • ...read more
  • View 2 more answers
    Q14. Circular Move

    You have a robot currently standing at the origin (0, 0) of a two-dimensional grid and facing north direction. You are given a sequence of moves for the robot in the form of a string of size 'N'. Y...read more

    Add your answer
    Q15. Kth Smallest and Largest Element of Array

    You are given an array ‘Arr’ consisting of ‘N’ distinct integers and a positive integer ‘K’. Find out Kth smallest and Kth largest element of the array. It is guaranteed...read more

    View 4 more answers
    Q16. Parity Move

    Ninja recently studied odd and even numbers but he is more interested in even numbers.

    He has an array ‘A’ containing ‘N’ integers. He will transform this array by moving all the even numbers at the ...read more

    View 2 more answers
    Q17. Anagram Pairs

    Pre-requisites: Anagrams are defined as words or names that can be formed by rearranging letters of another word. Such as "spar" can be formed by rearranging letters of "rasp". Hence, "spar" and "r...read more

    View 2 more answers
    Q18. Odd even level

    Given a binary tree. Find and return the modulus of the difference between the sum of odd level nodes and the sum of even level nodes.

    Input format:
    The first line contains an integer 'T' which de...read more
    View 2 more answers
    Q19. Prerequisite Task

    You are given a positive integer ‘N’ denoting the number of tasks you need to finish. You can directly start performing any task, but some tasks have some prerequisites, i.e. to perform some ta...read more

    View 2 more answers
    Q20. Search In A Row Wise And Column Wise Sorted Matrix

    You are given an N * N matrix of integers where each row and each column is sorted in increasing order. You are given a target integer 'X'. Find the position of...read more

    View 3 more answers
    Q21. Longest Palindromic Substring

    Given a string ’S’ consisting of lower case English letters, you are supposed to return the longest palindromic substring of ‘S’.

    Note that in case of more than one longest palindro...read more

    View 3 more answers
    Q22. House Robber

    Mr. X is a professional robber planning to rob houses along a street. Each house has a certain amount of money hidden. All houses along this street are arranged in a circle. That means the first hou...read more

    Ans.

    The task is to find the maximum amount of money Mr. X can rob from houses arranged in a circle without alerting the police.

    • The problem can be solved using dynamic programming.

    • Create two arrays to store the maximum amount of money robbed when considering the first house and when not considering the first house.

    • Iterate through the array and update the maximum amount of money robbed at each house.

    • The final answer will be the maximum of the last element in both arrays.

    View 1 answer
    Q23. Bridges In A Graph

    Given an undirected graph of V vertices and E edges. Your task is to find all the bridges in the given undirected graph. A bridge in any graph is defined as an edge which, when removed, makes ...read more

    View 2 more answers
    Q24. Basic HR Question

    What do you know about Paytm?

    Add your answer
    Q25. DBMS Questions

    What is Normalisation and different Normal Forms for a Relational Table?
    What is Indexing?
    A discussion on Fn. dependencies

    Add your answer
    Q26. OS Questions

    What is spooling?
    What are the conditions for deadlock to occur?

    Add your answer
    Q27. Java Question

    How is Linked List Implemented in java and when will you prefer it over ArrayList

    Add your answer
    Q28. Puzzle

    There are 12 coins. 11 of them have same weight and one is light in weight than others. We have a weighing balance. Find the minimum times we have to balance to find out the lighter one.

    Add your answer
    Q29. OOPS Questions

    OOPs Questions,
    Discussion on Singelton Design Pattern

    Add your answer
    Q30. OS Questions

    Theory questions about OS . Multithreading, Scheduling Algorithms

    Add your answer
    Q31. SQL Question

    A nested SQL query

    Add your answer
    Contribute & help others!
    Write a review
    Share interview
    Contribute salary
    Add office photos
    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
    Get AmbitionBox app

    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