KEMBAR78
Most Asked Question (Coding) | PDF | String (Computer Science) | Algorithms
0% found this document useful (0 votes)
18 views6 pages

Most Asked Question (Coding)

The document provides a comprehensive list of 10 questions for each of the common topics encountered in the TCS NQT exam, including Arrays, Strings, Linked Lists, Dynamic Programming, Sorting and Searching, Mathematical Problems, Greedy Algorithms, Trees, Graph Algorithms, and Bit Manipulation. Each topic contains a variety of problems designed to test different programming and algorithmic skills. This structured approach helps candidates prepare effectively for the exam.

Uploaded by

Mr X
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views6 pages

Most Asked Question (Coding)

The document provides a comprehensive list of 10 questions for each of the common topics encountered in the TCS NQT exam, including Arrays, Strings, Linked Lists, Dynamic Programming, Sorting and Searching, Mathematical Problems, Greedy Algorithms, Trees, Graph Algorithms, and Bit Manipulation. Each topic contains a variety of problems designed to test different programming and algorithmic skills. This structured approach helps candidates prepare effectively for the exam.

Uploaded by

Mr X
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Here's a list of 10 questions for each of the common topics you might

encounter in the TCS NQT exam.


1. Arrays
1. Find the missing number in an array of integers from 1 to n.
2. Rotate an array by k positions to the right.
3. Find the maximum product of two integers in an array.
4. Move all zeroes in an array to the end without changing the order of non-zero elements.
5. Find the subarray with the largest sum.
6. Find the first non-repeating element in an array.
7. Rearrange an array such that every even index contains the greater value and odd indices contain the smaller value.
8. Find all pairs in an array that sum up to a given value.
9. Given an array, check if it contains duplicate elements.
10. Given a sorted array, find the position of a given element using binary search.

2. Strings
1. Reverse a string.
2. Check if a string is a palindrome.
3. Find the longest common prefix in a list of strings.
4. Count the number of vowels in a string.
5. Find all the anagrams of a string in a list of words.
6. Implement run-length encoding for a string.
7. Convert a string to an integer (without using built-in functions like int()).
8. Given a string, find the first non-repeated character.
9. Check if two strings are rotations of each other.
10. Given a string, find the length of the longest substring without repeating characters.

3. Linked Lists
1. Detect if a linked list has a cycle.
2. Reverse a singly linked list.
3. Merge two sorted linked lists.
4. Find the middle element of a linked list.
5. Delete a node from a linked list, given only access to that node.
6. Find the nth node from the end of a linked list.
7. Check if a linked list is a palindrome.
8. Find the intersection point of two linked lists.
9. Flatten a linked list (i.e., convert it into a singly linked list if it contains sublists).
10. Split a circular linked list into two halves.

4. Dynamic Programming
1. Compute the nth Fibonacci number using dynamic programming.
2. Solve the 0/1 Knapsack problem.
3. Find the minimum number of coins needed to make a given amount (coin change problem).
4. Find the longest increasing subsequence in an array.
5. Solve the "minimum path sum in a grid" problem.
6. Find the maximum sum subarray (Kadane’s algorithm).
7. Count the number of ways to climb a staircase when you can take 1 or 2 steps at a time.
8. Solve the "edit distance" problem (minimum number of operations to convert one string into another).
9. Solve the "partition problem" (can an array be split into two subsets with equal sum?).
10. Solve the "house robber" problem (maximize the money robbed from houses arranged in a circle).

5. Sorting and Searching


1. Implement binary search on a sorted array.
2. Sort an array using Quick Sort.
3. Implement Merge Sort algorithm.
4. Find the kth smallest/largest element in an unsorted array.
5. Find the peak element in an array.
6. Implement Bubble Sort.
7. Sort an array of 0s, 1s, and 2s (Dutch National Flag problem).
8. Find the majority element in an array (if any).
9. Implement Insertion Sort.
10. Given a rotated sorted array, find the minimum element.

6. Mathematical Problems
1. Check if a number is prime.
2. Find the GCD (Greatest Common Divisor) of two numbers using Euclid's algorithm.
3. Count the number of trailing zeroes in a factorial of a number.
4. Find the sum of digits of a number.
5. Find the LCM (Least Common Multiple) of two numbers.
6. Implement a function to compute the power of a number (x^y).
7. Find the factorial of a number.
8. Implement a function to check if a number is a perfect square.
9. Find the number of set bits in a number (Hamming weight).
10. Find the nth Fibonacci number using dynamic programming.

7. Greedy Algorithms
1. Solve the activity selection problem.
2. Solve the fractional knapsack problem.
3. Find the minimum number of coins required to make a sum (coin change problem).
4. Schedule jobs such that the total profit is maximized (job sequencing problem).
5. Find the minimum spanning tree of a graph (Prim’s or Kruskal’s algorithm).
6. Solve the interval scheduling problem.
7. Solve the problem of finding the largest sum contiguous subarray (Kadane’s algorithm).
8. Assign jobs to workers such that the makespan is minimized.
9. Find the minimum number of platforms required for a railway station.
10. Solve the Huffman coding problem.

8. Trees
1. Implement Preorder, Inorder, and Postorder tree traversal.
2. Find the height of a binary tree.
3. Check if a binary tree is balanced.
4. Find the Lowest Common Ancestor (LCA) of two nodes in a binary tree.
5. Convert a binary tree into its mirror.
6. Check if a binary tree is a valid Binary Search Tree (BST).
7. Find the diameter of a binary tree (longest path between any two nodes).
8. Find the level of a given node in a binary tree.
9. Given a binary tree, print all nodes at a given distance from a node.
10. Find the sum of all leaf nodes in a binary tree.

9. Graph Algorithms
1. Implement Depth-First Search (DFS).
2. Implement Breadth-First Search (BFS).
3. Check if a graph is connected (using DFS/BFS).
4. Find the shortest path between two nodes in an unweighted graph (BFS).
5. Implement Dijkstra's algorithm for shortest path (weighted graph).
6. Find the number of connected components in a graph.
7. Find the topological sort of a directed acyclic graph (DAG).
8. Detect a cycle in a directed or undirected graph.
9. Implement Bellman-Ford algorithm for shortest path.
10. Solve the problem of finding Strongly Connected Components (SCCs) using Tarjan’s or Kosaraju’s algorithm.

10. Bit Manipulation


1. Check if a number is a power of 2.
2. Count the number of set bits (1s) in an integer.
3. Swap two numbers without using a temporary variable (using XOR).
4. Find the two non-repeating elements in an array where every element repeats twice.
5. Implement bitwise AND, OR, and XOR operations for two numbers.
6. Find the only non-repeating element in an array where all other elements repeat twice.
7. Find the position of the rightmost set bit in an integer.
8. Check if a number is a palindrome in binary form.
9. Calculate the Hamming distance between two numbers.
10. Reverse the bits of an integer.

You might also like