Software Engineer

1000+ Software Engineer Interview Questions and Answers for Freshers

Updated 2 Mar 2025
search-icon

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

Ans.

Merge nodes between zeroes in a linked list to store the 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

  • Handle edge cases like empty list or single node between zeroes

  • Ensure the list starts and ends with a zero

Q52. Cube of Matrix Problem Statement

Given a 2D array 'MATRIX' of size M x N, find and return the value (i * i + j * j) for those elements where the sum of the cubes of its digits equals the element itself. Here, '...read more

Ans.

Given a 2D array, find elements where sum of cube of digits equals element itself and return (i * i + j * j) value.

  • Iterate through the 2D array and check if the sum of cube of digits equals the element itself.

  • Calculate (i * i + j * j) for such elements and return the values.

  • If no such element exists, return -1.

Q53. Matrix Multiplication Task

Given two sparse matrices MAT1 and MAT2 of integers with dimensions 'N' x 'M' and 'M' x 'P' respectively, the goal is to determine the resulting matrix produced by their multiplicatio...read more

Ans.

Implement a function to multiply two sparse matrices and return the resulting matrix.

  • Create a function that takes two sparse matrices as input and returns the resulting matrix after multiplication.

  • Iterate through the non-zero elements of the matrices to perform the multiplication efficiently.

  • Ensure to handle the sparse nature of the matrices to optimize the multiplication process.

  • Consider the constraints provided to ensure the function works within the specified limits.

  • Test t...read more

Q54. Maximum Path Sum in a Matrix

Given an N*M matrix filled with integer numbers, determine the maximum sum that can be obtained from a path starting from any cell in the first row to any cell in the last row.

You ...read more

Ans.

Find the maximum sum path in a matrix from top row to bottom row by moving down or diagonally.

  • Use dynamic programming to keep track of maximum sum at each cell.

  • At each cell, consider the maximum sum from the cell above, left diagonal, and right diagonal.

  • Add the current cell value to the maximum of the three possibilities.

  • Repeat this process for all cells in the matrix to find the maximum sum path.

Are these interview questions helpful?

Q55. Reverse the String Problem Statement

You are given a string STR which contains alphabets, numbers, and special characters. Your task is to reverse the string.

Example:

Input:
STR = "abcde"
Output:
"edcba"

Input...read more

Ans.

The task is to reverse a given string containing lowercase letters, uppercase letters, digits, and special characters.

  • Iterate through the string from the last character to the first character and append each character to a new string.

  • Alternatively, you can use built-in string reversal functions or methods available in your programming language.

  • To solve the follow-up question with O(1) space complexity, you can use a two-pointer approach. Initialize two pointers, one at the be...read more

Q56. Cycle Detection in a Singly Linked List

Determine if a given singly linked list of integers forms a cycle or not.

A cycle in a linked list occurs when a node's next points back to a previous node in the list. T...read more

Ans.

Detect if a singly linked list forms a cycle by checking if a node's next points back to a previous node.

  • Traverse the linked list using two pointers, one moving one step at a time and the other moving two steps at a time.

  • If the two pointers meet at any point, it indicates the presence of a cycle in the linked list.

  • If one of the pointers reaches the end of the list (null), it means there is no cycle.

Frequently asked in,

Share interview questions and help millions of jobseekers 🌟

man-with-laptop

Q57. Car Pooling Capacity Problem

You are a cab driver with a car that initially has 'C' empty seats. The car moves in a straight line towards the forward direction only. Your job is to determine if it is possible t...read more

Ans.

Determine if it is possible to accommodate all passenger trips within a car's capacity without exceeding it at any point.

  • Iterate through each trip and keep track of the total number of passengers in the car at each point.

  • Check if the total number of passengers exceeds the car capacity at any point.

  • Return 'True' if all trips can be accommodated within the car capacity, otherwise return 'False'.

Q58. Sum Of Zeroes Coverage Calculation

You are provided with a binary matrix containing dimensions 'N * M', comprised only of 0s and 1s. Your task is to compute the aggregated sum of coverages for all the zeros in ...read more

Software Engineer Jobs

Software Engineer-AEM Developer 4-6 years
CATERPILLAR INDIA PRIVATE LTD
4.3
Chennai
Software Engineer-AEM Developer 3-7 years
Caterpillar Brazil
4.3
Chennai
Senior Engineer, Software Engineering 5-10 years
S&P Global Inc.
4.2
Hyderabad / Secunderabad

Q59. 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
Ans.

Check if two binary trees are mirrors of each other based on specific criteria.

  • Compare the roots of both trees.

  • Check if the left subtree of the first tree is the mirror of the right subtree of the second tree.

  • Verify if the right subtree of the first tree is the mirror of the left subtree of the second tree.

Q60. Kth Smallest Element Problem Statement

You are provided with an array of integers ARR of size N and an integer K. Your task is to find and return the K-th smallest value present in the array. All elements in th...read more

Q61. Left Rotations of an Array

You are given an array consisting of N elements and need to perform Q queries on that array. Each query consists of an integer indicating the number of elements by which the array sho...read more

Ans.

Perform left rotations on an array based on given queries.

  • Create a function that takes the array, number of elements, number of queries, and the queries as input.

  • For each query, rotate the array by the specified number of elements to the left.

  • Return the final array after each rotation query.

Q62. Determine Pythagoras' Position for Parallelogram Formation

Euclid, Pythagoras, Pascal, and Monte decide to gather in a park. Initially, Pascal, Monte, and Euclid choose three different spots. Pythagoras, arrivi...read more

Ans.

Calculate Pythagoras' coordinates to form a parallelogram with Euclid, Pascal, and Monte.

  • Calculate the midpoint of the line segment between Euclid and Monte to get the coordinates of Pythagoras.

  • Use the formula: x = x3 + (x2 - x1), y = y3 + (y2 - y1) to find Pythagoras' coordinates.

  • Ensure that the coordinates of Pythagoras satisfy the conditions for forming a parallelogram.

Q63. Sort Linked List Based on Actual Values

Given a Singly Linked List of integers that are sorted based on their absolute values, the task is to sort the linked list based on the actual values.

The absolute value ...read more

Ans.

Sort a Singly Linked List based on actual values instead of absolute values.

  • Traverse the linked list and store the values in an array.

  • Sort the array based on actual values.

  • Update the linked list with the sorted values.

Q64. You have a cuboid (m*n*p) each block of the cuboid is having a metallic ball. Now we are passing X-ray from front face and getting a bool matrix1 of m*p the elements are set if there is a black spot.(as we are...

read more
Ans.

Yes, it is possible to get the accurate result from the given data.

  • The coordinates (i,j,k) where metallic balls are present can be determined by finding the set elements in both matrix1 and matrix2.

  • Additional data is not required as the given data is sufficient to determine the coordinates.

  • The coordinates can be obtained by iterating through the elements of matrix1 and matrix2 and checking for set elements.

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

Ans.

Given 'N' ropes of varying lengths, find the minimum cost to connect all ropes into one single rope.

  • Sort the lengths of ropes in ascending order.

  • Keep connecting the two shortest ropes at each step.

  • Add the cost of connecting the two ropes to the total cost.

  • Repeat until all ropes are connected.

  • Return the total cost as the minimum cost to connect all ropes.

Q66. Kth Largest Element Problem Statement

Ninja enjoys working with numbers, and Alice challenges him to find the Kth largest value from a given list of numbers.

Input:

The first line contains an integer 'T', repre...read more
Ans.

The task is to find the Kth largest element from a given list of numbers for each test case.

  • Read the number of test cases 'T'

  • For each test case, read the number of elements 'N' and the Kth largest number to find 'K'

  • Sort the array in descending order and output the Kth element

Q67. Minimum Cost to Buy Oranges Problem Statement

You are given a bag of capacity 'W' kg and a list 'cost' of costs for packets of oranges with different weights. Each element at the i-th position in the list indic...read more

Ans.

Find the minimum cost to purchase a specific weight of oranges given the cost of different weight packets.

  • Iterate through the list of costs and find the minimum cost to achieve the desired weight

  • Keep track of the total cost while considering available packet weights

  • Return -1 if it is not possible to buy exactly the desired weight

Q68. Minimum Umbrellas Problem

You are provided with ‘N’ types of umbrellas, where each umbrella type can shelter a certain number of people. Given an array UMBRELLA that indicates the number of people each umbrella...read more

Ans.

The problem involves determining the minimum number of umbrellas required to shelter a specific number of people based on the capacity of each umbrella.

  • Iterate through the array of umbrella capacities to find the combination that covers exactly 'M' people.

  • Keep track of the minimum number of umbrellas used to cover 'M' people.

  • If it is not possible to cover 'M' people exactly, return -1.

  • Example: For input [2, 3, 4] and M=5, the minimum number of umbrellas required is 2 (2-capac...read more

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

Ans.

The problem involves finding the number of distinct ways to climb N stairs by taking 1 or 2 steps at a time.

  • Use dynamic programming to solve the problem efficiently.

  • The number of ways to reach the Nth stair is the sum of the number of ways to reach the (N-1)th stair and the (N-2)th stair.

  • Handle base cases for N=0 and N=1 separately.

  • Consider using modulo operation to avoid overflow for large values of N.

Frequently asked in, ,

Q70. Decimal to Octal Conversion Problem Statement

Convert a given decimal number into its equivalent octal representation.

Explanation:

The octal number system is a base-8 system, meaning each digit ranges from 0 t...read more

Ans.

Convert decimal numbers to octal representation.

  • Iterate through each test case and use built-in functions to convert decimal to octal.

  • Ensure the output is in base-8 system with digits ranging from 0 to 7.

  • Handle constraints such as number of test cases and range of decimal numbers.

Q71. Kth Largest Element Problem

Given an array containing N distinct positive integers and a number K, determine the Kth largest element in the array.

Example:

Input:
N = 6, K = 3, array = [2, 1, 5, 6, 3, 8]
Output...read more
Ans.

Find the Kth largest element in an array of distinct positive integers.

  • Sort the array in non-increasing order and return the Kth element.

  • Ensure all elements in the array are distinct.

  • Handle multiple test cases efficiently.

Q72. LCA in a Binary Search Tree

You are given a binary search tree (BST) containing N nodes. Additionally, you have references to two nodes, P and Q, within this BST.

Your task is to determine the Lowest Common Anc...read more

Ans.

The task is to find the Lowest Common Ancestor (LCA) of two nodes in a Binary Search Tree (BST).

  • Traverse the BST from the root to find the LCA of nodes P and Q.

  • Compare the values of nodes P and Q with the current node's value to determine the LCA.

  • If both nodes are on the same side of the current node, move to that side; otherwise, the current node is the LCA.

  • Example: For input 2 3 and BST 1 2 3 4 -1 5 6 -1 7 -1 -1 -1 -1 -1 -1, the LCA is node 1.

Q73. Print Series Problem Statement

Given two positive integers N and K, your task is to generate a series of numbers by subtracting K from N until the result is 0 or negative, then adding K back until it reaches N ...read more

Ans.

Generate a series of numbers by subtracting K from N until 0 or negative, then adding K back to reach N without using loops.

  • Create a recursive function to generate the series.

  • Subtract K from N until N is 0 or negative, then add K back until N is reached.

  • Return the series as an array of integers.

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

Ans.

The task is to identify all distinct triplets within an array that sum up to a specified number.

  • Iterate through the array and use nested loops to find all possible triplets.

  • Check if the sum of the triplet equals the specified number.

  • Print the valid triplets or return -1 if no triplet exists.

Frequently asked in,

Q75. Word Occurrence Counting

Given a string 'S' of words, the goal is to determine the frequency of each word in the string. Consider a word as a sequence of one or more non-space characters. The string can have mu...read more

Q76. Cycle Detection in Undirected Graph Problem Statement

You are provided with an undirected graph containing 'N' vertices and 'M' edges. The vertices are numbered from 1 to 'N'. Your objective is to determine whe...read more

Ans.

Detect cycles in an undirected graph with given vertices and edges.

  • Use Depth First Search (DFS) to traverse the graph and detect cycles.

  • Maintain a visited array to keep track of visited vertices and a parent array to keep track of the parent of each vertex.

  • If while traversing, you encounter a visited vertex that is not the parent of the current vertex, then a cycle exists.

  • Consider edge cases like disconnected graphs and self-loops.

Q77. Kruskal’s Minimum Spanning Tree Algorithm Problem Statement

You are given a connected undirected weighted graph. Your task is to determine the weight of the minimum spanning tree of this graph.

A minimum spanni...read more

Ans.

The task is to determine the weight of the minimum spanning tree of a given connected undirected weighted graph.

  • Implement Kruskal's algorithm to find the minimum spanning tree weight.

  • Sort the edges based on their weights in non-decreasing order.

  • Iterate through the sorted edges and add them to the MST if they don't form a cycle.

  • Keep track of the total weight of the MST and return it as the output.

Q78. Maximum Subarray Sum Problem Statement

Given an array arr of length N consisting of integers, find the sum of the subarray (including empty subarray) with the maximum sum among all subarrays.

Explanation:

A sub...read more

Ans.

Find the sum of the subarray with the maximum sum among all subarrays in an array of integers.

  • Iterate through the array and keep track of the maximum sum subarray seen so far.

  • At each index, decide whether to include the current element in the subarray or start a new subarray.

  • Update the maximum sum subarray if a new maximum is found.

  • Consider edge cases like all negative numbers in the array.

  • Example: For input arr = [-2, 1, -3, 4, -1], the maximum subarray sum is 4.

Q79. Rectangle Area Calculation

Given a list of rectangles, where each rectangle is represented by an array of four integers indicating its bottom-left and top-right corners, calculate the total area covered by all ...read more

Ans.

Calculate total area covered by a list of rectangles on a plane.

  • Iterate through each rectangle and calculate its area

  • Check for overlapping areas between rectangles

  • Sum up the total area covered by all rectangles

Q80. SpecialStack Design Problem

Design a stack that efficiently supports the getMin() operation in O(1) time with O(1) extra space. This stack should include the following operations: push(), pop(), top(), isEmpty(...read more

Ans.

Design a stack that supports getMin() operation in O(1) time with O(1) extra space using inbuilt stack data structure.

  • Use two stacks - one to store the actual data and another to store the minimum value at each level.

  • When pushing a new element, check if it is smaller than the current minimum and update the minimum stack accordingly.

  • When popping an element, also pop the top element from the minimum stack if it matches the popped element.

  • For getMin() operation, simply return th...read more

Q81. String Transformation Problem

Given a string (STR) of length N, you are tasked to create a new string through the following method:

Select the smallest character from the first K characters of STR, remove it fr...read more

Ans.

Given a string and an integer K, create a new string by selecting the smallest character from the first K characters of the input string and repeating the process until the input string is empty.

  • Iterate through the input string, selecting the smallest character from the first K characters each time.

  • Remove the selected character from the input string and append it to the new string.

  • Continue this process until the input string is empty.

  • Return the final new string formed.

Q82. there are 2 processors each executing a separate program- processor 1 int a=10 int *ptr = &a; ptr is written into file1 processor sleeps for 10sec printf("%d",a); processor 2 int *p; file1 is read and contents...

read more
Ans.

The output will be 5.

  • Processor 1 initializes variable 'a' with a value of 10 and creates a pointer 'ptr' pointing to 'a'.

  • Processor 1 writes the value of 'ptr' into 'file1' and then sleeps for 10 seconds.

  • Processor 2 reads the contents of 'file1' and saves it in pointer 'p'.

  • Processor 2 assigns the value 5 to the memory location pointed by 'p'.

  • When Processor 1 wakes up and executes the printf statement, it will print the updated value of 'a', which is 5.

Q83. two puzzles: 1. how can you cut a cake in 8 pieces in minimum number of cuts(answered) ,2.make 4 equilateral triangles using 6 matchsticks(answered)

Ans.

1. Cut cake in 8 pieces in minimum cuts. 2. Make 4 equilateral triangles using 6 matchsticks.

  • 1. Cut cake in half horizontally and vertically. Cut each quarter diagonally.

  • 2. Use 3 matchsticks to form a triangle. Use the other 3 to connect the centers of each triangle.

  • Both puzzles require creative thinking and problem-solving skills.

Q84. Unique Element In Sorted Array

Nobita wants to impress Shizuka by correctly guessing her lucky number. Shizuka provides a sorted list where every number appears twice, except for her lucky number, which appears...read more

Ans.

Find the unique element in a sorted array where all other elements appear twice.

  • Iterate through the array and XOR all elements to find the unique element.

  • Use a hash set to keep track of elements and find the unique one.

  • Sort the array and check adjacent elements to find the unique one.

Q85. Given 2 game scenarios for basketball, and given p as the probability of making a basket in an attempt, I have to understand the condition where game1 would be preferable over game2. In first game, I have one t...

read more
Ans.

Comparing 2 basketball game scenarios with different number of trials and baskets required to win

  • Calculate the probability of winning in each game scenario using binomial distribution formula

  • Compare the probabilities to determine which game scenario is preferable

  • In game1, the probability of winning is p. In game2, the probability of winning is the sum of probabilities of making 2 or 3 baskets

  • If p is high, game1 is preferable. If p is low, game2 is preferable

  • For example, if p ...read more

Q86. Middle of a Linked List

You are given the head node of a singly linked list. Your task is to return a pointer pointing to the middle of the linked list.

If there is an odd number of elements, return the middle ...read more

Ans.

Return the middle node of a singly linked list, considering odd and even number of elements.

  • Traverse the linked list with 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

  • Return the node pointed by the slow pointer

Q87. Write a C code to delete a node from circular doubly linked list where you cannot delete the head node.. (At the last i was very eager to know the answers to the questions he asked me, But he refused to answer...

read more
Ans.

C code to delete a node from circular doubly linked list without deleting the head node.

  • Start from the head node and traverse the list until the desired node is found.

  • Update the next and previous pointers of the adjacent nodes to skip the node to be deleted.

  • Free the memory allocated for the node to be deleted.

Q88. Subsequence Determination Problem

Your task is to verify if the given string STR1 is a subsequence of the string STR2. A subsequence means characters from STR2 are retained in their original order but some (or ...read more

Ans.

Verify if a string is a subsequence of another string by checking if characters are retained in order.

  • Iterate through both strings simultaneously, checking if characters match in order.

  • If a character in STR1 matches a character in STR2, move to the next character in STR2.

  • If all characters in STR1 are found in STR2 in order, return True; otherwise, return False.

Q89. Are you okay to learn front end and back end technologies to ensure you are a complete developer in the longer run? Would you be able to learn the concepts if a timeline is given?? If yes, explain your learning...

read more
Ans.

Yes, I am willing to learn front end and back end technologies and have a learning strategy in place.

  • I believe in continuous learning and growth as a developer.

  • I have experience in learning new technologies quickly and efficiently.

  • My learning strategy involves breaking down concepts into smaller parts and practicing regularly.

  • I also utilize online resources and seek guidance from experienced colleagues.

  • Examples of technologies I have learned include React, Node.js, and MongoD...read more

Q90. Remove Invalid Parentheses

Given a string containing only parentheses and letters, your goal is to remove the minimum number of invalid parentheses to make the input string valid and return all possible valid s...read more

Ans.

Given a string with parentheses and letters, remove minimum invalid parentheses to make it valid and return all possible valid strings.

  • Use BFS to explore all possible valid strings by removing parentheses one by one

  • Keep track of visited strings to avoid duplicates

  • Return all unique valid strings obtained after removing minimum number of parentheses

Q91. Reverse Alternate K Nodes Problem Statement

You are given a singly linked list of integers along with a positive integer 'K'. The task is to modify the linked list by reversing every alternate 'K' nodes of the ...read more

Ans.

Reverse every alternate K nodes in a singly linked list of integers.

  • Traverse the linked list in groups of K nodes and reverse every alternate group.

  • Handle cases where the number of remaining nodes is less than K.

  • Ensure to properly link the reversed groups to maintain the integrity of the linked list.

Q92. All Root to Leaf Paths in Binary Tree

You have a binary tree containing 'N' nodes labeled from 1 to 'N'. Your objective is to enumerate every path from the root to each leaf.

A leaf is defined as a node with no...read more

Ans.

The task is to print all the root to leaf paths of an arbitrary binary tree.

  • Traverse the binary tree using depth-first search (DFS) algorithm

  • Maintain a current path list to keep track of the nodes in the current path

  • When reaching a leaf node, add the current path to the result list

  • Recursively explore the left and right subtrees

  • Remove the last node from the current path after exploring each subtree

Q93. Count Diagonal Paths

You are given a binary tree. Your task is to return the count of the diagonal paths to the leaf of the given binary tree such that all the values of the nodes on the diagonal are equal.

Inp...read more

Ans.

Count the number of diagonal paths in a binary tree with equal node values.

  • Traverse the binary tree and keep track of diagonal paths with equal node values.

  • Use recursion to explore all possible paths in the tree.

  • Count the number of paths that meet the criteria of having equal node values on the diagonal.

Q94. Segregate Even and Odd Nodes in a Linked List

You are given the head node of a singly linked list head. Your task is to modify the linked list so that all the even-valued nodes appear before all the odd-valued ...read more

Ans.

Reorder a singly linked list so that all even-valued nodes appear before odd-valued nodes while preserving the original order.

  • Create two separate linked lists for even and odd nodes

  • Traverse the original list and move nodes to respective even or odd lists

  • Merge the even and odd lists while maintaining the original order

Q95. Tic-Tac-Toe Design Problem

Design a 2-player Tic-Tac-Toe game played on an N * N grid where Player 1 uses ‘X’ and Player 2 uses ‘O’. A move is always valid and occupies an empty spot.

If a player places N of th...read more

Ans.

Design a 2-player Tic-Tac-Toe game on an N x N grid where players place their marks to win by getting N marks in a row.

  • Create a 2D array to represent the game board.

  • Implement a function to check for a win after each move.

  • Handle player moves and update the board accordingly.

  • Return the result of each move (0, 1, or 2) based on the game state.

  • Consider horizontal, vertical, and diagonal win conditions.

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

Ans.

The task is to distribute chocolates among students such that the difference between the largest and smallest number of chocolates is minimized.

  • Sort the array of chocolates packets

  • Use sliding window technique to find the minimum difference between the largest and smallest number of chocolates distributed to students

  • Return the minimum difference

Frequently asked in,

Q97. Design a Constant Time Data Structure

Create a data structure that maintains mappings between keys and values, supporting the following operations in constant time:

1. INSERT(key, value): Add or update the inte...read more
Ans.

Design a constant time data structure for key-value mappings with operations like INSERT, DELETE, SEARCH, GET, GET_SIZE, and IS_EMPTY.

  • Use a hash table to achieve constant time complexity for operations.

  • Implement INSERT, DELETE, SEARCH, GET, GET_SIZE, and IS_EMPTY functions.

  • Ensure key is a string and value is a positive integer.

  • Return appropriate results based on the operation type.

  • Handle edge cases like key not found or data structure being empty.

Q98. Find Nodes at a Specific Distance from Target in a Binary Tree

Given a binary tree, a target node within this tree, and an integer K, identify and return all nodes that are exactly K edges away from the target ...read more

Ans.

Find nodes at a specific distance from a target node in a binary tree.

  • Traverse the binary tree to find the target node.

  • Perform a depth-first search to identify nodes at distance K from the target node.

  • Return the values of nodes found at distance K in an array.

Q99. Given a list of words. Given three operations find out the minimum steps to reach from source string to destination string. Basically, -----/ this is the problem with some modification. For this question I said...

read more
Ans.

The question is about finding the minimum steps to reach from a source string to a destination string using three operations.

  • BFS and DFS are graph traversal techniques that can be used to solve this problem.

  • BFS is typically used when finding the shortest path or exploring all possible paths in a graph.

  • DFS is useful when searching for a specific path or exploring deeply into a graph.

  • In this case, BFS can be used to find the minimum steps to reach the destination string.

  • Create ...read more

Q100. Intersection of Linked List Problem

You are provided with two singly linked lists containing integers, where both lists converge at some node belonging to a third linked list.

Your task is to determine the data...read more

Ans.

Find the node where two linked lists merge, return -1 if no merging occurs.

  • Traverse both lists to find the lengths and the last nodes

  • Align the starting points of the lists by adjusting the pointers

  • Traverse both lists simultaneously until a common node is found

Frequently asked in,
Previous
1
2
3
4
5
6
7
Next
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Interview experiences of popular companies

3.7
 • 10.4k Interviews
3.8
 • 8.1k Interviews
3.6
 • 7.5k Interviews
3.7
 • 5.6k Interviews
3.8
 • 5.6k Interviews
3.7
 • 4.7k Interviews
3.5
 • 3.8k Interviews
3.5
 • 3.8k Interviews
3.8
 • 2.9k Interviews
View all

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

Software Engineer Interview Questions
Share an Interview
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter