Software Engineer, new Grad
Software Engineer, new Grad Interview Questions and Answers

Asked in Google

Q. There is a train that passes through a series of junctions (switches). Each junction indicates the path the train will take, and after the train passes, the switch at that junction changes direction. Given M ju...
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

Asked in Google

Q. Write a program to solve the 15-Puzzle game. Given a matrix, where one block is empty, align them in the correct order.
A program to solve the 15-Puzzle by rearranging tiles into the correct order using an empty space.
The 15-Puzzle consists of a 4x4 grid with 15 numbered tiles and one empty space.
The goal is to arrange the tiles in ascending order from 1 to 15, with the empty space at the bottom right.
Use algorithms like A* or BFS for finding the solution efficiently.
Example initial state: [[12, 2, 3, 4], [10, 6, 7, 1], [9, 11, 5, 13], [8, 14, 15, '']].
Example goal state: [[1, 2, 3, 4], [5, 6,...read more

Asked in Google

Q. Given the root of a binary search tree (BST), return the level order traversal of its nodes' values. (i.e., from left to right, level by level).
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

Asked in Google

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

Asked in Google

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

Asked in Google

Q. Given a 2D grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four...
read moreCount 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

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

