Associate Software Engineer
400+ Associate Software Engineer Interview Questions and Answers for Freshers
Q1. Triplets with Given Sum Problem
Given an array or list ARR
consisting of N
integers, your task is to identify all distinct triplets within the array that sum up to a specified number K
.
Explanation:
A triplet i...read more
Q2. Intersection of Two Arrays II
Given two integer arrays ARR1
and ARR2
of size N
and M
respectively, find the intersection of these arrays. An intersection refers to elements that appear in both arrays.
Note:
Inp...read more
Q3. Connecting Ropes with Minimum Cost
You are given 'N' ropes, each of varying lengths. The task is to connect all ropes into one single rope. The cost of connecting two ropes is the sum of their lengths. Your obj...read more
The problem is to connect N ropes of different lengths into one rope with minimum cost.
Sort the array of rope lengths in ascending order.
Initialize a variable to keep track of the total cost.
While there are more than one rope remaining, take the two shortest ropes and connect them.
Add the cost of connecting the two ropes to the total cost.
Replace the two shortest ropes with the connected rope.
Repeat the above steps until only one rope remains.
Return the total cost as the mini...read more
Q4. Factorial Trailing Zeros Problem
You are provided with a positive integer N. Your goal is to determine the smallest number whose factorial has at least N trailing zeros.
Example:
Input:
N = 1
Output:
5
Explanat...read more
Q5. Ninja and Alternating Largest Problem Statement
Ninja is given a sequence of numbers and needs to rearrange them so that every second element is greater than its neighbors on both sides.
Example:
Input:
[1, 2, ...read more
The task is to rearrange the given array such that every second element is greater than its left and right element.
Read the number of test cases
For each test case, read the number of elements in the array and the array elements
Iterate through the array and swap elements at odd indices with their adjacent elements if necessary
Check if the rearranged array satisfies the conditions and print 1 if it does, else print 0
Q6. Armstrong Number Problem Statement
You are provided an integer 'NUM'. Determine if 'NUM' is an Armstrong number.
Explanation:
An integer 'NUM' with 'k' digits is an Armstrong number if the sum of its digits, ea...read more
Share interview questions and help millions of jobseekers 🌟
Q7. Intersection of Linked List Problem Statement
You are provided with two singly linked lists of integers. These lists merge at a node of a third linked list.
Your task is to determine the data of the node where ...read more
Q8. Kth Smallest and Largest Element Problem Statement
You are provided with an array 'Arr' containing 'N' distinct integers and a positive integer 'K'. Your task is to find the Kth smallest and Kth largest element...read more
Associate Software Engineer Jobs
Q9. Reverse Linked List Problem Statement
Given a singly linked list of integers, your task is to return the head of the reversed linked list.
Example:
Input:
The given linked list is 1 -> 2 -> 3 -> 4 -> NULL.
Outp...read more
Q10. Palindrome String Validation
Determine if a given string 'S' is a palindrome, considering only alphanumeric characters and ignoring spaces and symbols.
Note:
The string 'S' should be evaluated in a case-insensi...read more
Q11. Add K Nodes Problem Statement
You are given a singly linked list of integers and an integer 'K'. Your task is to modify the linked list by inserting a new node after every 'K' node in the linked list. The value...read more
Q12. Longest Common Prefix After Rotation
You are given two strings 'A' and 'B'. While string 'A' is constant, you may apply any number of left shift operations to string 'B'.
Explanation:
Your task is to calculate ...read more
The question asks to find the minimum number of left shift operations required to obtain the longest common prefix of two given strings.
Perform left shift operations on string B to find the longest common prefix with string A
Count the number of left shift operations required to obtain the longest common prefix
Return the minimum number of left shift operations for each test case
Q13. Tiling Problem Statement
Given a board with 2 rows and N columns, and an infinite supply of 2x1 tiles, determine the number of distinct ways to completely cover the board using these tiles.
You can place each t...read more
Q14. Pair Sum Problem Statement
You are given an integer array 'ARR' of size 'N' and an integer 'S'. Your task is to find and return a list of all pairs of elements where each sum of a pair equals 'S'.
Note:
Each pa...read more
Q15. Combination Sum Problem Statement
Given three integers X
, Y
, and Z
, calculate the sum of all numbers that can be formed using the digits 3, 4, and 5. Each digit can be used up to a maximum of X
, Y
, and Z
times ...read more
Q16. Equilibrium Index Problem Statement
Given an array Arr
consisting of N integers, your task is to find the equilibrium index of the array.
An index is considered as an equilibrium index if the sum of elements of...read more
Q17. Find First Repeated Character in a String
Given a string 'STR' composed of lowercase English letters, identify the character that repeats first in terms of its initial occurrence.
Example:
Input:
STR = "abccba"...read more
Q18. Balanced Parentheses Combinations
Given an integer N
representing the number of pairs of parentheses, find all the possible combinations of balanced parentheses using the given number of pairs.
Explanation:
Con...read more
Q19. Chocolate Distribution Problem
You are given an array/list CHOCOLATES
of size 'N', where each element represents the number of chocolates in a packet. Your task is to distribute these chocolates among 'M' stude...read more
Q20. Find Middle of Linked List
Given the head node of a singly linked list, your task is to return a pointer pointing to the middle node of the linked list.
When the number of elements is odd, return the middle ele...read more
Q21. One of the questions for Critical Reasoning was:- Two cars A and B cross a flyover in 10 minutes and 30 minutes respectively. Find the speed of Car A. Statements: Car B travels at the 50kmph Train A and B are t...
read moreCar A's speed is 90kmph
Use the formula: Speed = Distance/Time
Assume the distance to be the same for both cars
Calculate Car A's time using the given information
Substitute the values in the formula to get Car A's speed
Q22. Longest Path In Directed Graph Problem Statement
Given a Weighted Directed Acyclic Graph (DAG) comprising 'N' nodes and 'E' directed edges, where nodes are numbered from 0 to N-1, and a source node 'Src'. Your ...read more
Q23. Sub Sort Problem Statement
You are given an integer array ARR
. Determine the length of the shortest contiguous subarray which, when sorted in ascending order, results in the entire array being sorted in ascendi...read more
The question asks to find the length of the shortest contiguous subarray that needs to be sorted in order to sort the whole array.
Iterate through the array and find the first element that is out of order from the left side.
Iterate through the array and find the first element that is out of order from the right side.
Find the minimum and maximum element within the subarray from the above steps.
Expand the subarray from both sides until all elements within the subarray are in the...read more
Q24. Largest BST Subtree Problem
Given a binary tree with 'N' nodes, determine the size of the largest subtree that is also a BST (Binary Search Tree).
Input:
The first line contains an integer 'T', representing the...read more
Q25. Prime Time Again Problem Statement
You are given two integers DAY_HOURS
and PARTS
. Consider a day with DAY_HOURS
hours, which can be divided into PARTS
equal parts. Your task is to determine the total instances...read more
Q26. Pythagorean Triplets Detection
Determine if an array contains a Pythagorean triplet by checking whether there are three integers x, y, and z such that x2 + y2 = z2 within the array.
Input:
The first line contai...read more
Q27. Find the Longest Palindromic Substring
Given a string ‘S’ composed of lowercase English letters, your task is to identify the longest palindromic substring within ‘S’.
If there are multiple longest palindromic ...read more
Q28. N-th Term Of Geometric Progression
Find the N-th term of a Geometric Progression (GP) series given the first term A, the common ratio R, and the term position N.
Explanation:
The general form of a GP series is ...read more
Q29. 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
Q30. Infix to Postfix Conversion
You are provided with a string EXP
which represents a valid infix expression. Your task is to convert this given infix expression into a postfix expression.
Explanation:
An infix exp...read more
Q31. Nth Fibonacci Number Problem Statement
Calculate the Nth term in the Fibonacci sequence, where the sequence is defined as follows: F(n) = F(n-1) + F(n-2)
, with initial conditions F(1) = F(2) = 1
.
Input:
The inp...read more
Q32. Buy and Sell Stock Problem Statement
Imagine you are Harshad Mehta's friend, and you have been given the stock prices of a particular company for the next 'N' days. You can perform up to two buy-and-sell transa...read more
Q33. Decode String Problem Statement
Your task is to decode a given encoded string back to its original form.
Explanation:
An encoded string format is
Q34. Minimum Number of Platforms Needed Problem Statement
You are given the arrival and departure times of N trains at a railway station for a particular day. Your task is to determine the minimum number of platform...read more
Q35. Longest Increasing Subsequence Problem Statement
Given an array of integers with 'N' elements, determine the length of the longest subsequence where each element is greater than the previous element. This subse...read more
Q36. Ninja and Substrings Problem Statement
Ninja has to determine all the distinct substrings of size two that can be formed from a given string 'STR' comprising only lowercase alphabetic characters. These substrin...read more
The task is to find all the different possible substrings of size two that appear in a given string as contiguous substrings.
Iterate through the string and extract substrings of size two
Store the substrings in an array
Return the array of substrings
Q37. Question 2 was, Find the sum of all numbers in range from 1 to m(both inclusive) that are not divisible by n. Return difference between sum of integers not divisible by n with sum of numbers divisible by n.
Find sum of numbers in range 1 to m (both inclusive) not divisible by n. Return difference between sum of non-divisible and divisible numbers.
Iterate through range 1 to m and check if number is divisible by n.
If not divisible, add to sum of non-divisible numbers.
If divisible, add to sum of divisible numbers.
Return difference between sum of non-divisible and divisible numbers.
Q38. Implementing a Priority Queue Using Heap
Ninja has been tasked with implementing a priority queue using a heap data structure. However, he is currently busy preparing for a tournament and has requested your ass...read more
Q39. Bipartite Graph Problem Statement
Determine if a given graph is bipartite. A graph is bipartite if its vertices can be divided into two independent sets, 'U' and 'V', such that every edge ('u', 'v') connects a ...read more
The function checks whether a given graph is bipartite or not.
A bipartite graph can be divided into two independent sets such that every edge connects a vertex from one set to the other.
We can use graph coloring algorithm to check if the graph is bipartite.
Start by coloring the first vertex with one color and all its neighbors with the other color.
Continue coloring the remaining vertices, making sure that no adjacent vertices have the same color.
If at any point, we find that ...read more
Q40. Constellation Identification Problem
Given a matrix named UNIVERSE
with 3 rows and 'N' columns, filled with characters {#, *, .}, where:
- '*' represents stars.
- '.' represents empty space.
- '#' represents a separ...read more
Q41. Find First Unique Character in a String
You are given a string S
of length N
. Your task is to find the index (considering 1-based indexing) of the first unique character in the string. If there are no unique ch...read more
Q42. Ways To Make Coin Change
Given an infinite supply of coins of varying denominations, determine the total number of ways to make change for a specified value using these coins. If it's not possible to make the c...read more
Q43. Remove Vowels from a Given String
Given a string STR
of length N
, your task is to remove all the vowels present in that string and return the modified string.
Explanation:
English alphabets ‘a’, ‘e’, ‘i’, ‘o’, ...read more
Q44. Replace Spaces in a String
Given a string STR
consisting of words separated by spaces, your task is to replace all spaces between words with the characters "@40".
Input:
The first line contains an integer ‘T’ d...read more
Q45. 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
Q46. Stack using Two Queues Problem Statement
Develop a Stack Data Structure to store integer values using two Queues internally.
Your stack implementation should provide these public functions:
Explanation:
1. Cons...read more
Q47. Colorful Knapsack Problem
You are given a set of 'N' stones, each with a specific weight and color. The goal is to fill a knapsack with exactly 'M' stones, choosing one stone of each color, so that the total we...read more
Q48. DFS Traversal Problem Statement
Given an undirected and disconnected graph G(V, E)
, where V
is the number of vertices and E
is the number of edges, the connections between vertices are provided in the 'GRAPH' m...read more
The question asks to print the DFS traversal of an undirected and disconnected graph.
Implement a Depth First Search (DFS) algorithm to traverse the graph.
Use a visited array to keep track of visited vertices.
For each unvisited vertex, start a DFS traversal and print the connected component.
Sort the vertices of each connected component in ascending order before printing.
Q49. Find the Second Largest Element
Given an array or list of integers 'ARR', identify the second largest element in 'ARR'.
If a second largest element does not exist, return -1.
Example:
Input:
ARR = [2, 4, 5, 6, ...read more
Q50. Check if Two Trees are Mirror
Given two arbitrary binary trees, your task is to determine whether these two trees are mirrors of each other.
Explanation:
Two trees are considered mirror of each other if:
- The r...read more
Interview Questions of Similar Designations
Top Interview Questions for Associate Software Engineer 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