Associate Software Engineer
500+ Associate Software Engineer Interview Questions and Answers for Freshers

Asked in Samsung

Q. 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
The task is to find all distinct triplets in an array that sum up to a specified number.
Iterate through the array and use nested loops to find all possible triplets.
Keep track of the triplets that sum up to the target number.
Handle cases where no triplet exists for a given target sum.

Asked in Hexaware Technologies

Q. 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
Find the intersection of two integer arrays in the order they appear in the first array.
Iterate through the first array and store elements in a hashmap with their frequencies.
Iterate through the second array and check if the element exists in the hashmap, decrement frequency if found.
Return the elements that have non-zero frequencies as the intersection.

Asked in Accenture

Q. Write a function to determine if a given string is a valid password based on the following criteria: - At least 4 characters - At least one numeric digit - At least one capital letter - Must not have space or s...
read moreValid password must have at least 4 characters, one numeric digit, one capital letter, no space or slash, and cannot start with a number.
Password must be at least 4 characters long
Password must contain at least one numeric digit
Password must contain at least one capital letter
Password cannot have space or slash (/)
Password cannot start with a number

Asked in Amazon

Q. 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

Asked in Micron Technology

Q. 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
Modify a singly linked list by inserting a new node after every 'K' nodes with the sum of previous 'K' nodes.
Traverse the linked list while keeping track of 'K' nodes at a time
Calculate the sum of the 'K' nodes and insert a new node with the sum after every 'K' nodes
Handle the case where the number of remaining nodes is less than 'K' by inserting a node with the sum of remaining nodes
Update the pointers accordingly to maintain the linked list structure

Asked in NRI Financial Technologies

Q. Suppose you have to send an unbreakable box along with its key from Kolkata to Delhi such that no one in between can open the box and read the letter. You need to send both the lock and key; anyone getting both...
read moreUse a 3-way encryption method to securely send a box and key from Kolkata to Delhi.
1. Split the message into three parts: A, B, and C.
2. Encrypt part A with the recipient's public key.
3. Encrypt part B with the sender's public key.
4. Send parts A and B separately to the recipient.
5. Send part C unencrypted, as it contains no sensitive information.
6. The recipient can decrypt parts A and B using their private key and the sender's public key.
Associate Software Engineer Jobs




Asked in Salesforce

Q. 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
Find the smallest number whose factorial has at least N trailing zeros.
Calculate the number of 5's in the prime factorization of the factorial to determine the trailing zeros.
Use binary search to find the smallest number with at least N trailing zeros.
Consider edge cases like N = 0 or N = 1 for factorial trailing zeros problem.

Asked in ACKO

Q. 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
Share interview questions and help millions of jobseekers 🌟

Asked in Ernst & Young

Q. 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
Given two linked lists, find the node where they intersect, if any.
Traverse both lists to find their lengths and the difference in lengths
Move the pointer of the longer list by the difference in lengths
Traverse both lists in parallel until they meet at the intersection node

Asked in Accenture

Q. Two cars A and B cross a flyover in 10 minutes and 30 minutes respectively. Given that Car B travels at 50kmph and Train A and B are travelling in opposite directions, find the speed of Car A.
Car 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

Asked in Amazon

Q. 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
Generate all possible combinations of balanced parentheses given the number of pairs.
Use backtracking to generate all valid combinations of balanced parentheses.
Keep track of the number of open and close parentheses used in each combination.
Recursively build the combinations by adding open parentheses if there are remaining, and then adding close parentheses if the number of open parentheses is greater than the number of close parentheses.
Example: For N = 2, valid combination...read more

Asked in DE Shaw

Q. 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
Distribute chocolates among students to minimize the difference between the largest and smallest number of chocolates.
Sort the array of chocolates packets.
Use sliding window technique to find the minimum difference between the largest and smallest packets distributed to students.
Return the minimum difference as the output.

Asked in Amazon

Q. 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
Find the Kth smallest and largest elements in an array.
Sort the array and return the Kth element for smallest and (N-K+1)th element for largest.
Ensure K is within the array size to avoid out of bounds error.
Handle multiple test cases efficiently by iterating through each case.

Asked in Amazon

Q. 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
Find pairs of elements in an array that sum up to a given value, sorted in a specific order.
Iterate through the array and for each element, check if the complement (S - current element) exists in a hash set.
If the complement exists, add the pair to the result list.
Sort the result list based on the criteria mentioned in the problem statement.

Asked in Accenture

Q. 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
An Armstrong number is a number that is equal to the sum of its own digits raised to the power of the number of digits.
Iterate through each digit of the number and calculate the sum of each digit raised to the power of the total number of digits.
Compare the calculated sum with the original number to determine if it is an Armstrong number.
Return 'YES' if the number is an Armstrong number, 'NO' otherwise.

Asked in LinkedIn

Q. 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
Calculate the sum of all numbers that can be formed using the digits 3, 4, and 5 with given constraints.
Iterate through all possible combinations of 3, 4, and 5 based on the given constraints.
Calculate the sum of each combination and add them up.
Return the final sum modulo 10^9 + 7.

Asked in Bharti Airtel

Q. 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

Asked in Nagarro

Q. 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
Find the equilibrium index of an array where sum of elements on left equals sum on right.
Iterate through the array and calculate the total sum of all elements.
For each index, calculate the left sum and right sum and check if they are equal.
Return the index if found, otherwise return -1.

Asked in Samsung

Q. 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
To reverse a singly linked list of integers, return the head of the reversed linked list.
Iterate through the linked list, reversing the pointers to point to the previous node instead of the next node.
Keep track of the previous, current, and next nodes while traversing the list.
Update the head of the reversed linked list to be the last element of the original list.

Asked in Amazon

Q. 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
Convert a given infix expression to postfix expression.
Use a stack to keep track of operators and operands.
Follow the rules of precedence for operators (*, / have higher precedence than +, -).
Handle parentheses by pushing them onto the stack and popping when closing parenthesis is encountered.

Asked in Adobe

Q. 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
The problem involves finding the number of distinct ways to completely cover a 2xN board using 2x1 tiles.
Use dynamic programming to solve the tiling problem efficiently.
Define a recursive function to calculate the number of ways to tile the board.
Consider both horizontal and vertical placements of tiles.
Implement the function to handle large values of N by using modulo arithmetic.
Optimize the solution to avoid redundant calculations.

Asked in Delhivery

Q. Decode String Problem Statement
Your task is to decode a given encoded string back to its original form.
Explanation:
An encoded string format is <count>[encoded_string], where the 'encoded_string' inside the s...read more
The task is to decode an encoded string back to its original form by repeating the encoded string 'count' times.
Parse the input string to extract the count and the encoded string within the brackets
Use recursion to decode the encoded string by repeating it 'count' times
Handle nested encoded strings by recursively decoding them
Output the decoded string for each test case

Asked in Accenture

Q. 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
Return the middle node of a singly linked list, selecting the one farther from the head node in case of even number of elements.
Traverse the linked list using two pointers, one moving twice as fast as the other.
When the fast pointer reaches the end, the slow pointer will be at the middle node.
Return the node pointed by the slow pointer as the middle node.

Asked in Tech Mahindra

Q. Can you call the base class method without creating an instance?
Yes, by using the super() method in the derived class.
super() method calls the base class method
Derived class must inherit from the base class
Example: class Derived(Base): def method(self): super().method()

Asked in Accenture

Q. Find the sum of all numbers in the range from 1 to m (inclusive) that are not divisible by n. Return the difference between the sum of integers not divisible by n and the 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.

Asked in Salesforce

Q. 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
The task is to find the longest distances from a source node to all nodes in a weighted directed acyclic graph.
Implement a function that takes the number of nodes, edges, source node, and edge weights as input.
Use a topological sorting algorithm to traverse the graph and calculate the longest distances.
Return an array of integers where each element represents the longest distance from the source node to the corresponding node.

Asked in Cuemath

Q. 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
Calculate the N-th term of a Geometric Progression series given the first term, common ratio, and term position.
Iterate through each test case and apply the formula A * R^(N-1) to find the N-th term
Use modular arithmetic to handle large calculated terms by returning the result modulo 10^9 + 7

Asked in MagicBricks

Q. 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

Asked in Tredence

Q. 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
The task is to find the first repeated character in a given string of lowercase English letters.
Iterate through the string and keep track of characters seen so far in a set.
If a character is already in the set, return it as the first repeated character.
If no repeated character is found, return '%'.

Asked in Salesforce

Q. 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
The problem involves finding the size of the largest subtree that is also a Binary Search Tree in a given binary tree.
Traverse the binary tree in a bottom-up manner to check if each subtree is a BST.
Keep track of the size of the largest BST subtree encountered so far.
Use recursion to solve the problem efficiently.
Consider edge cases like empty tree or single node tree.
Example: For input 1 2 3 4 -1 5 6 -1 7 -1 -1 -1 -1 -1 -1, the largest BST subtree has size 3.
Interview Questions of Similar Designations
Interview Experiences of Popular Companies





Top Interview Questions for Associate Software Engineer Related Skills

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

