Technical Trainee
40+ Technical Trainee Interview Questions and Answers for Freshers
Q1. Minimum Cost to Destination
You are given an NxM matrix consisting of '0's and '1's. A '1' signifies that the cell is accessible, whereas a '0' indicates that the cell is blocked. Your task is to compute the mi...read more
Find the minimum cost to reach a destination in a matrix with specified rules.
Use Breadth First Search (BFS) algorithm to explore all possible paths from the starting point to the destination.
Keep track of the cost incurred at each cell and update it as you move through the matrix.
Return the minimum cost to reach the destination or -1 if it is unreachable.
Consider edge cases such as when the starting point is the destination or when the destination is blocked.
Q2. Maximum of All Subarrays of Size k
Given an array of 'N' non-negative integers and an integer 'K', your task is to find the maximum elements for each subarray of size 'K'.
Input:
The first line contains an inte...read more
Find the maximum elements for each subarray of size 'K' in a given array of non-negative integers.
Iterate through the array and maintain a deque to store the indices of elements in decreasing order.
Pop elements from the deque if they are out of the current window of size 'K'.
The front of the deque will always have the index of the maximum element for the current window.
Q3. Sum Between Zeroes Problem Statement
Given a singly linked list containing a series of integers separated by the integer '0', modify the list by merging nodes between two '0's into a single node. This merged no...read more
Given a singly linked list with integers separated by '0', merge nodes between '0's into a single node with sum of included nodes.
Traverse the linked list and keep track of sum between zeroes
Merge nodes between zeroes by updating the sum in the merged node
Update the linked list by removing the nodes between zeroes
Handle edge cases like list starting and ending with '0'
Q4. Nth Prime Number Problem Statement
Find the Nth prime number given a number N.
Explanation:
A prime number is greater than 1 and is not the product of two smaller natural numbers. A prime number has exactly two...read more
Find the Nth prime number given a number N.
A prime number is greater than 1 and is not the product of two smaller natural numbers
A prime number has exactly two distinct positive divisors: 1 and itself
Implement a function to find the Nth prime number based on the given input
Q5. Counting Derangements Problem
A derangement is a permutation of 'N' elements, where no element appears in its original position. For instance, a derangement of {0, 1, 2, 3} is {2, 3, 1, 0} because each element ...read more
Count the total number of derangements possible for a set of 'N' elements.
A derangement is a permutation where no element appears in its original position.
Use the formula for derangements: !n = n! * (1 - 1/1! + 1/2! - 1/3! + ... + (-1)^n/n!)
Return the answer modulo (10^9 + 7) to handle large results.
Q6. Convert Min Heap to Max Heap Problem Statement
Given an array representation of a min-heap of size 'n', your task is to convert this array into a max-heap.
Input:
The first line of input contains an integer ‘T’...read more
Convert a given array representing a min-heap into a max-heap.
Iterate through the array and swap parent nodes with their children to convert min-heap to max-heap.
Maintain the heap property by comparing parent with its children and swapping if necessary.
Ensure the final array satisfies the max-heap property where parent nodes are greater than their children.
Share interview questions and help millions of jobseekers 🌟
Q7. Closest Distance Pair Problem Statement
Given an array containing 'N' points in a 2D plane, determine the minimum distance between the closest pair of points.
Note:
Distance between two points (x1, y1) and (x2,...read more
The task is to find the distance of the closest points among an array of N points in the plane.
Calculate the distance between each pair of points using the given formula
Keep track of the minimum distance found so far
Return the minimum distance
Q8. Count Palindrome Words in a String
Given a string 'S' consisting of words, your task is to determine the number of palindrome words within 'S'. A word is considered a palindrome if it reads the same backward as...read more
Count the number of palindrome words in a given string.
Split the string into words using whitespace as delimiter.
Check each word if it is a palindrome by comparing it with its reverse.
Increment a counter for each palindrome word found.
Output the total count of palindrome words for each test case.
Technical Trainee Jobs
Q9. 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
Sort an integer array containing only 0s, 1s, and 2s in-place using a single scan.
Iterate through the array and maintain three pointers for 0s, 1s, and 2s.
Swap elements based on the current element's value and the pointers.
Example: If current element is 0, swap with the 0s pointer and increment both pointers.
Q10. Build Max Heap Problem Statement
Given an integer array with N elements, the task is to transform this array into a max binary heap structure.
Explanation:
A max-heap is a complete binary tree where each intern...read more
The task is to transform an integer array into a max binary heap structure.
Create a max heap from the given array by rearranging elements.
Check if each internal node has a value greater than or equal to its children.
Output '1' if the transformed array represents a max-heap, else output '0'.
Q11. Swap Two Numbers Problem Statement
Given two integers a
and b
, your task is to swap these numbers and output the swapped values.
Input:
The first line contains a single integer 't', representing the number of t...read more
Swap two integers 'a' and 'b' and output the swapped values.
Create a temporary variable to store one of the integers before swapping
Assign the value of 'a' to 'b' and the temporary variable to 'a'
Output the swapped values as 'b' followed by 'a'
Q12. Merge Sort Problem Statement
You are given a sequence of numbers, ARR
. Your task is to return a sorted sequence of ARR
in non-descending order using the Merge Sort algorithm.
Explanation:
The Merge Sort algorit...read more
Implement Merge Sort algorithm to sort a sequence of numbers in non-descending order.
Divide the input array into two halves recursively until each array has only one element.
Merge the sorted halves to produce a completely sorted array.
Ensure the implementation handles the constraints specified in the problem statement.
Example: For input [3, 1, 4, 1, 5], the output should be [1, 1, 3, 4, 5].
Q13. Reverse Doubly Linked List Nodes in Groups
You are given a doubly linked list of integers along with a positive integer K
that represents the group size. Your task is to modify the linked list by reversing ever...read more
Reverse groups of K nodes in a doubly linked list.
Iterate through the linked list in groups of K nodes
Reverse each group of K nodes
Handle cases where the number of nodes is less than K
Update the pointers accordingly
Q14. Character Formation Check
Determine if the second string STR2
can be constructed using characters from the first string STR1
. Both strings may include any characters.
Input:
The first line contains an integer T...read more
Check if second string can be formed using characters from the first string.
Iterate through each character in STR2 and check if it exists in STR1.
Use a hashmap to store the frequency of characters in STR1 for efficient lookup.
Return 'YES' if all characters in STR2 are found in STR1, otherwise return 'NO'.
Q15. Detect and Remove Loop in Linked List
For a given singly linked list, identify if a loop exists and remove it, adjusting the linked list in place. Return the modified linked list.
Expected Complexity:
Aim for a...read more
Detect and remove loop in a singly linked list in place with O(n) time complexity and O(1) space complexity.
Use Floyd's Cycle Detection Algorithm to identify the loop in the linked list.
Once the loop is detected, use two pointers to find the start of the loop.
Adjust the pointers to remove the loop and return the modified linked list.
Q16. Trapping Rainwater Problem Statement
You are given an array ARR
of long type, which represents an elevation map where ARR[i]
denotes the elevation of the ith
bar. Calculate the total amount of rainwater that ca...read more
Calculate the total amount of rainwater that can be trapped within given elevation map.
Iterate through the array to find the maximum height on the left and right of each bar.
Calculate the amount of water that can be trapped above each bar by taking the minimum of the maximum heights on the left and right.
Sum up the trapped water above each bar to get the total trapped water for the elevation map.
Q17. Count Ways to Reach the N-th Stair Problem Statement
You are provided with a number of stairs, and initially, you are located at the 0th stair. You need to reach the Nth stair, and you can climb one or two step...read more
The problem involves determining the number of distinct ways to climb from the 0th to the Nth stair by climbing one or two steps at a time.
Use dynamic programming to solve this problem efficiently.
The number of ways to reach the Nth stair can be calculated by adding the number of ways to reach the (N-1)th stair and the (N-2)th stair.
Consider base cases where N=0 and N=1 separately.
Handle large values of N by using modulo arithmetic.
Example: For N=3, the number of distinct way...read more
Q18. Sorted Linked List to Balanced BST Problem Statement
Given a singly linked list where nodes contain values in increasing order, your task is to convert it into a Balanced Binary Search Tree (BST) using the same...read more
Convert a sorted linked list into a Balanced Binary Search Tree (BST) using the same data values.
Create a function to convert the linked list to a BST by recursively dividing the list into halves
Maintain a pointer to the middle element of the list as the root of the BST
Recursively set the left and right children of the root using the left and right halves of the list
Perform level order traversal to output the values of the BST nodes in the required format
Q19. Snake and Ladder Problem Statement
Given a 'Snake and Ladder' board with N rows and N columns, where positions are numbered from 1 to (N*N) starting from the bottom left, alternating direction each row, find th...read more
Find the minimum number of dice throws required to reach the last cell on a 'Snake and Ladder' board.
Create a graph representation of the board with snakes and ladders as edges.
Use Breadth First Search (BFS) to find the shortest path from the starting cell to the last cell.
Keep track of visited cells and the number of dice throws at each cell.
Handle cases where the last cell is unreachable by returning -1.
Consider the special cases where the last cell is reached through a lad...read more
Q20. Spiral Order Traversal of a Binary Tree
Given a binary tree with N
nodes, your task is to output the Spiral Order traversal of the binary tree.
Input:
The input consists of a single line containing elements of ...read more
The task is to output the Spiral Order traversal of a binary tree given in level order.
Implement a function that returns the spiral order traversal as a list
Traverse the binary tree in a spiral order alternating between left to right and right to left
Use a queue to keep track of nodes at each level
Handle null nodes represented by -1 in the input
Q21. Distribute N Candies Among K People
Explanation: Sanyam wishes to distribute 'N' candies among 'K' friends. The friends are arranged based on Sanyam's order of likeness. He initially distributes candies such th...read more
Distribute N candies among K people in Sanyam's order of likeness, incrementing distribution by K each round until all candies are distributed.
Distribute candies starting from 1st friend, incrementing by K each round
If remaining candies are fewer than what a friend is supposed to receive, stop distribution
Output the number of candies each friend ends up with at the end of distribution
Q22. Find All Pairs Adding Up to Target
Given an array of integers ARR
of length N
and an integer Target
, your task is to return all pairs of elements such that they add up to the Target
.
Input:
The first line conta...read more
The task is to find all pairs of elements in an array that add up to a given target.
Iterate through the array and for each element, check if the target minus the element exists in a hash set.
If it exists, add the pair to the result. If not, add the element to the hash set.
Print the pairs found or (-1, -1) if no pair is found.
Q23. Jumping Game Problem Statement
In this problem, you have ‘n’ carrots lined up and denoted by numbers 1 through ‘n’. There are ‘k’ rabbits, and each rabbit can jump to carrots that are multiples of its unique ju...read more
Calculate uneaten carrots after rabbits jump based on their unique factors.
Iterate through each rabbit's jumping factor and mark the carrots they land on as eaten
Calculate the remaining uneaten carrots by counting the ones not marked as eaten
Consider using a data structure like an array to keep track of eaten carrots efficiently
Q24. Reverse Linked List Problem Statement
Given a Singly Linked List of integers, your task is to reverse the Linked List by altering the links between the nodes.
Input:
The first line of input is an integer T, rep...read more
Reverse a singly linked list by altering the links between nodes.
Iterate through the linked list and reverse the links between nodes
Use three pointers to keep track of the current, previous, and next nodes
Update the links between nodes to reverse the list
Return the head of the reversed linked list
Q25. Reverse Stack with Recursion
Reverse a given stack of integers using recursion. You must accomplish this without utilizing extra space beyond the internal stack space used by recursion. Additionally, you must r...read more
Reverse a given stack of integers using recursion without extra space or loop constructs.
Use recursion to pop all elements from the original stack and store them in function call stack.
Once the stack is empty, push the elements back in reverse order using recursion.
Ensure to handle base cases for empty stack or single element stack.
Example: If the input stack is [1, 2, 3], after reversal it should be [3, 2, 1].
Q26. String Compression Problem Statement
Ninja needs to perform basic string compression. For any character that repeats consecutively more than once, replace the repeated sequence with the character followed by th...read more
Implement a function to compress a string by replacing consecutive characters with the character followed by the count of repetitions.
Iterate through the input string and keep track of consecutive characters and their counts.
Replace consecutive characters with the character followed by the count of repetitions if count is greater than 1.
Return the compressed string for each test case.
Q27. Trapping Rain Water Problem Statement
You are given a long type array/list ARR
of size N
, representing an elevation map. The value ARR[i]
denotes the elevation of the ith
bar. Your task is to determine the tota...read more
Calculate the total amount of rainwater that can be trapped between given elevations in an array.
Iterate through the array and calculate the maximum height on the left and right of each bar.
Calculate the amount of water that can be trapped at each bar by taking the minimum of the maximum heights on the left and right.
Sum up the trapped water at each bar to get the total trapped water for the entire array.
Q28. Maximum Sum Path in a Binary Tree
Your task is to determine the maximum possible sum of a simple path between any two nodes (possibly the same) in a given binary tree of 'N' nodes with integer values.
Explanati...read more
Find the maximum sum of a simple path between any two nodes in a binary tree.
Use a recursive approach to traverse the binary tree and calculate the maximum sum path.
Keep track of the maximum sum path found so far while traversing the tree.
Consider negative values in the path sum calculation to handle cases where the path can start and end at different nodes.
Handle cases where the path can go through the root node or not.
Q29. Properties of MST in an Undirected Graph
You have a simple undirected graph G = (V, E)
where each edge has a distinct weight. Consider an edge e
as part of this graph. Determine which of the given statements re...read more
In an undirected graph with distinct edge weights, the lightest edge in a cycle is included in every MST, while the heaviest edge is excluded.
The lightest edge in a cycle is always included in every MST of the graph.
The heaviest edge in a cycle is always excluded from every MST of the graph.
This property holds true for all simple undirected graphs with distinct edge weights.
Q30. Find The Closest Perfect Square Problem Statement
You are given a positive integer N
. Your task is to find the perfect square number that is closest to N
and determine the number of steps required to reach that...read more
Find the closest perfect square to a given positive integer and determine the number of steps required to reach that number.
Iterate through perfect squares starting from 1 until the square is greater than the given number
Calculate the distance between the perfect square and the given number
Return the closest perfect square and the distance as output
Q31. How would you take feedbacks and structure a lecture plan accordingly?
I would actively listen to feedback, analyze it, and make necessary adjustments to the lecture plan.
Actively listen to feedback from students, colleagues, and supervisors.
Analyze the feedback to identify common themes or areas for improvement.
Make necessary adjustments to the lecture plan based on the feedback received.
Seek clarification or additional feedback if needed to ensure understanding.
Implement changes in a timely manner to improve the effectiveness of the lecture.
Q32. Colour coding of transistor and what is soldering how it works.
Transistor colour coding helps identify the type and polarity of the transistor. Soldering is a process of joining two metal surfaces using a filler metal.
Transistor colour coding typically involves using colored bands to indicate the type and polarity of the transistor. For example, a common NPN transistor might have a black body with a white band to indicate the base, a red band for the collector, and a green band for the emitter.
Soldering is the process of joining two meta...read more
Q33. How to protect the network and data?
Protecting network and data involves implementing security measures to prevent unauthorized access and data breaches.
Implement strong passwords and two-factor authentication
Use firewalls and antivirus software
Regularly update software and security patches
Encrypt sensitive data
Train employees on safe browsing and email practices
Limit access to sensitive data on a need-to-know basis
Regularly backup data
Q34. What is dns how it will use?
DNS stands for Domain Name System. It is a decentralized system that translates domain names into IP addresses.
DNS is used to resolve domain names to their corresponding IP addresses.
It helps in the efficient routing of internet traffic.
DNS also provides other services like email routing and load balancing.
Example: When you type a website URL in your browser, DNS translates it to the IP address of the server hosting that website.
Q35. Can you draw a simple electrical circuit?
Yes, I can draw a simple electrical circuit.
Start with a power source (battery or outlet)
Connect the power source to a load (light bulb, resistor, etc.)
Include wires to complete the circuit
Label components with symbols (battery symbol, resistor symbol, etc.)
Q36. Standard of all chemical reactions @parameters
The standard parameters for chemical reactions include temperature, pressure, concentration, and catalysts.
Temperature: affects reaction rate and product yield
Pressure: affects reaction rate and equilibrium constant
Concentration: affects reaction rate and equilibrium constant
Catalysts: increase reaction rate without being consumed
Examples: Haber process, acid-base reactions, combustion reactions
Q37. What is packing
Packing is the process of arranging items into a container in a way that maximizes space and protects the items from damage during transportation.
Packing involves organizing items efficiently in a container or box
It is important to use appropriate packing materials such as bubble wrap, packing peanuts, or foam to protect fragile items
Proper packing can prevent items from shifting during transit and getting damaged
Examples of packing include packing clothes in a suitcase, pack...read more
Q38. Using firewalls
Firewalls are network security systems that monitor and control incoming and outgoing network traffic.
Firewalls can be hardware or software-based
They can be configured to block or allow specific traffic based on rules
Firewalls can prevent unauthorized access to a network
They can also be used to block malicious traffic and prevent attacks
Examples of firewalls include Cisco ASA, Fortinet FortiGate, and pfSense
Q39. What is abstract
Abstract is a concept or idea that is not concrete or tangible.
Abstract refers to something that exists in thought or as an idea, but not physically.
It is often used in art, literature, and philosophy to represent complex concepts or emotions.
Examples include abstract paintings, abstract reasoning, and abstract concepts like justice or love.
Q40. Explain inheritance
Inheritance is a concept in object-oriented programming where a class can inherit attributes and methods from another class.
Inheritance allows for code reusability and promotes the concept of hierarchy in programming
A subclass can inherit attributes and methods from a superclass
Subclasses can also add their own unique attributes and methods
Example: Class Animal can be a superclass with attributes like name and age, and subclasses like Dog and Cat can inherit these attributes
Q41. Explain oops concept
OOPs (Object-Oriented Programming) is a programming paradigm based on the concept of objects, which can contain data and code.
OOPs focuses on creating objects that interact with each other to solve a problem
Key principles include encapsulation, inheritance, polymorphism, and abstraction
Encapsulation: bundling data and methods that operate on the data into a single unit
Inheritance: allows a class to inherit properties and behavior from another class
Polymorphism: ability for ob...read more
Interview Questions of Similar Designations
Top Interview Questions for Technical Trainee Related Skills
Interview experiences of popular companies
Calculate your in-hand salary
Confused about how your in-hand salary is calculated? Enter your annual salary (CTC) and get your in-hand salary
Reviews
Interviews
Salaries
Users/Month