Software Engineer, new Grad
Software Engineer, new Grad Interview Questions and Answers
Q1. 1. There is a train that passes the following path: L / \ ... L / \ ... L Each junction tells us the path it is going to take. Once the train passes it'll change the switch at the function. We dont care after t...
read moreDetermining the state of switches/junctions after N trains have passed through them.
Create an array to represent the state of each switch/junction
Iterate through each train and update the state of the corresponding switch/junction
Use a loop to simulate the passing of trains and updating of switches/junctions
Return the final state of the switches/junctions
Q2. 2. Level order traversal of BST
Level order traversal of a binary search tree (BST) is a breadth-first search algorithm that visits each level of the tree from left to right.
Use a queue to keep track of the nodes to be visited
Start with the root node and enqueue it
While the queue is not empty, dequeue a node and visit it
Enqueue the left and right child of the visited node if they exist
Repeat until all nodes have been visited
Q3. 1. Move Zeros from Leetcode
Move all zeros to the end of the array while maintaining the relative order of the non-zero elements.
Iterate through the array and keep track of the index to place the next non-zero element.
When encountering a non-zero element, swap it with the element at the current index.
After iterating through the array, all zeros will be moved to the end while maintaining the order of non-zero elements.
Q4. 2. Merge subsets with small twist
Merge subsets of strings with a twist
Merge subsets of strings into a single array
The twist is that each subset should be reversed before merging
Return the merged array of reversed subsets
Q5. 4. Number of islands with a twist
Count the number of islands in a grid, where an island is a group of connected 1s.
Use depth-first search (DFS) or breadth-first search (BFS) to traverse the grid
For each cell with a 1, mark it as visited and explore its neighboring cells
Count the number of times you start a new DFS or BFS traversal
Software Engineer, new Grad Jobs
0Calculate 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