Nqt question pattern
Nqt question pattern
Number-Based Problems:
• Check for Leap Year: Write a program to determine if a given year is a leap year.
• Sum of First n Natural Numbers: Compute the sum of the first n natural numbers.
2. Array-Based Problems:
• Find Duplicates: Identify duplicates in an array in O(n) time and O(1) space.
• Find the Third Maximum Number: Given an array, find the third largest element.
• Sorting Arrays: Implement sorting algorithms such as Bubble Sort, Insertion Sort, Selection Sort.
3. String-Based Problems:
• Convert String Case: Convert lowercase characters of a string to uppercase and vice versa.
Remove Duplicates from a String: Eliminate duplicate characters from an input string.
• Bubble Sort: Implement the bubble sort algorithm for an integer array.
5. Conversions:
• String to Integer Conversion: Convert a string to an integer without using in-built functions like Integer.parseInt().
2. Fibonacci Sequence
5. Array Rotation
TCS Digital
o Given an array of integers, return the indices of the two numbers that add up to a specific target.
o Given a string, find the longest substring that contains no repeated characters.
6. Palindrome Number
o Move all the zeros to the end of an array while maintaining the relative order of other elements.
9. Valid Parentheses
o Given n stairs, find the number of ways you can climb the stairs (either 1 or 2 steps at a time).
TCS Ninja
3. Sum of Array Elements (The image cuts off here, but it's reasonable to assume this would ask for a program to
calculate the sum of all elements in an array.)
8. Factorial of a Number
9. Palindrome Number
o Sort an array containing only 0s, 1s, and 2s without using any sorting algorithm.
o Use the fast and slow pointer approach to find the middle node.
9. Binary Search
11. Find the nth Node from the End of a Linked List
o Given a linked list, find the nth node from the end.
o Design a stack that supports finding the minimum element in O(1) time.
o Given two strings, check whether they are anagrams of each other.
o Move all zeroes to the end of an array without affecting the order of non-zero elements.
3. Merge Intervals
o Calculate how much water can be trapped between bars after rain.
19. Merge K Sorted Linked Lists (The image cuts off here, but it's reasonable to assume this would ask to merge k
sorted linked lists into one sorted linked list.)
• Given an infinite supply of coins of different denominations, find the minimum number of coins to make a specific
amount.
o An array contains numbers from 1 to n with one number missing. Find the missing number.
6. Remove Duplicates from Unsorted Linked List (The rest of the list is cut off in the image.)
o Find the element that appears more than half the time in an array.
o Sort an array of 0s, 1s, and 2s without using any sorting algorithm.
o Check if a binary tree is a mirror of itself. (The image cuts off here, but it's likely the question would
continue as shown below.)
o Find all duplicate numbers in an array in O(n) time and constant space.
o Given a 2D board and a word, find if the word exists in the grid.
o Given an array, for each element find the next greater element.