Jio Platforms
10+ TCS Interview Questions and Answers
Q1. Rotting Oranges Problem Statement
You are given a grid containing oranges where each cell of the grid can contain one of the three integer values:
- 0 - representing an empty cell
- 1 - representing a fresh orange...read more
Find the minimum time required to rot all fresh oranges in a grid.
Use Breadth First Search (BFS) to simulate the rotting process.
Track the time taken to rot all oranges and return the result.
Handle edge cases like no fresh oranges or unreachable fresh oranges.
Consider using a queue to efficiently process adjacent oranges.
Q2. Circular Tour Problem Statement
Consider a circular path with N petrol pumps. Each pump is numbered from 0 to N-1. Every petrol pump provides:
- The amount of petrol available at the pump.
- The distance to the ne...read more
The task is to find the first petrol pump from which a truck can complete a full circle or determine if it's impossible.
Iterate through each petrol pump and calculate the remaining petrol after reaching the next pump.
If the remaining petrol is negative at any point, reset the starting pump to the next pump and continue.
If the total remaining petrol is non-negative after completing the circle, return the index of the starting pump.
If the total remaining petrol is negative afte...read more
Q3. Min Stack Problem Statement
Design a special stack that supports the following operations in constant time:
Push(num)
: Insert the given number into the stack.Pop
: Remove and return the top element from the st...read more
Design a special stack that supports constant time operations like push, pop, top, and getMin.
Use two stacks - one to store the elements and another to store the minimum values encountered so far
When pushing, check if the element is smaller than the current minimum and update the minimum stack accordingly
For pop, top, and getMin operations, simply access the top elements of the respective stacks
Ensure to handle cases where the stack is empty
Q4. Unique Paths Problem Statement
Given the dimensions of an M x N matrix, determine the total number of unique paths from the top-left corner to the bottom-right corner of the matrix.
Allowed moves are only to th...read more
The problem involves finding the total number of unique paths from the top-left corner to the bottom-right corner of an M x N matrix with allowed moves only to the right or down.
Use dynamic programming to solve the problem efficiently.
Create a 2D array to store the number of unique paths for each cell in the matrix.
Initialize the first row and first column with 1 as there is only one way to reach each cell in the first row and column.
For each cell (i, j), the number of unique...read more
Q5. Rotate Linked List Problem Statement
Given a linked list consisting of 'N' nodes and an integer 'K', your task is to rotate the linked list by 'K' positions in a clockwise direction.
Example:
Input:
Linked List...read more
Rotate a linked list by K positions in a clockwise direction.
Traverse the linked list to find the length and the last node.
Connect the last node to the head to form a circular linked list.
Find the new head by moving (length - K) steps from the original head.
Break the circular list at the new head to get the rotated linked list.
Q6. Binary Palindrome Check
Given an integer N
, determine whether its binary representation is a palindrome.
Input:
The first line contains an integer 'T' representing the number of test cases.
The next 'T' lines e...read more
Check if the binary representation of a given integer is a palindrome.
Convert the integer to binary representation.
Check if the binary representation is a palindrome by comparing it with its reverse.
Return true if it is a palindrome, false otherwise.
Q7. Print Fibonacci series
Print Fibonacci series
Start with 0 and 1 as the first two numbers
Add the previous two numbers to get the next number in the series
Repeat until desired number of terms is reached
Q8. rolling hash dsa problem
Rolling hash is a hashing technique used in data structures and algorithms to efficiently compare substrings of text.
Rolling hash is used in algorithms like Rabin-Karp string matching algorithm.
It involves updating the hash value of a substring by removing the contribution of the first character and adding the contribution of the next character.
It is useful for comparing substrings in constant time complexity.
Q9. Multi Threading in Java
Multi threading in Java allows multiple threads to execute concurrently, improving performance and responsiveness.
Multi threading is achieved in Java by extending the Thread class or implementing the Runnable interface.
Threads share the same memory space, allowing them to communicate and synchronize using methods like wait(), notify(), and notifyAll().
Concurrency issues like race conditions and deadlocks can occur in multi-threaded applications and must be carefully managed.
E...read more
Q10. Synchronization in Java
Synchronization in Java ensures that only one thread can access a shared resource at a time.
Synchronization is achieved using the synchronized keyword in Java.
It can be applied to methods or blocks of code.
Example: synchronized void myMethod() { // code }
Interview Process at TCS
Top Software Developer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month