Software Engineer, new Grad

Software Engineer, new Grad Interview Questions and Answers

Updated 2 Jul 2025

Asked in Google

1d ago

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

Determining 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

5d ago

Q. Write a program to solve the 15-Puzzle game. Given a matrix, where one block is empty, align them in the correct order.

Ans.

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

6d ago

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

Ans.

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

5d ago

Q. 1. Move Zeros from Leetcode

Ans.

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.

Are these interview questions helpful?

Asked in Google

1d ago

Q. 2. Merge subsets with small twist

Ans.

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

5d ago

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

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

Interview Experiences of Popular Companies

Google Logo
4.4
 • 895 Interviews
View all
interview tips and stories logo
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

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, new Grad Interview Questions
Share an Interview
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

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

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits