Top 15 Easy DSA Google interview questions

Kiran Maan
CodeMinds AI
Published in
5 min readFeb 28, 2024

--

Here, we will explore 15 basic DSA interview questions that are asked by Google in their interviews.

As promised in the previous blog, we are back with the top 15 DSA interview questions for Google. Just be ready to explore those 15 exciting questions.

But firstly we will start with easy questions to motivate you so you can also clear the Google interview. As we always hear getting placed in Google is just so hard. YES, it is true. But with your dedication and hard work, you can make it possible.

Now, we are getting started with the most common DSA Interview questions asked in Google interviews.

1. Add linked list:

Given two numbers represented by linked lists. Your task is to find the sum list and return the head of the sum list.

The sum list is a linked list representation of the addition of two numbers.

Try this question

2. Roman to Integer

Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.

Symbol       Value
I 1
V 5
X 10
L 50
C 100
D 500
M 1000

For example, 2 is written as II in Roman numeral, just two ones added together. 12 is written as, which is simply X + II. The number 27 is written as XXVII, which is XX + V + II.

Roman numerals are usually written from largest to smallest from left to right. However, the numeral for four is not IIII. Instead, the number four is written as IV. Because the one is before the five we subtract it making four. The same principle applies to the number nine, which is written as IX. There are six instances where subtraction is used:

  • I can be placed before V (5) and X (10) to make 4 and 9.
  • X can be placed before L (50) and C (100) to make 40 and 90.
  • C can be placed before D (500) and M (1000) to make 400 and 900.

Given a Roman numeral, convert it to an integer.

Try this question

3. Valid Parentheses

Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.

An input string is valid if:

  1. Open brackets must be closed by the same type of brackets.
  2. Open brackets must be closed in the correct order.
  3. Every close bracket has a corresponding open bracket of the same type.

Try this question!

4. Check If Linked List Is Palindrome

You are given a Singly Linked List of integers. You have to return true if the linked list is palindrome, else return false.

A Linked List is a palindrome if it reads the same from left to right and from right to left.

Try this question!

5. Plus One

You are given a large integer represented as an integer array digits, where each digits[i] is the ith digit of the integer. The digits are ordered from most significant to least significant in left-to-right order. The large integer does not contain any leading 0's.

Increment the large integer by one and return the resulting array of digits.

Try this question!

6. Painter’s Partition Problem

Given an array/list of length ’n’, where the array/list represents the boards and each element of the given array/list represents the length of each board. Some ‘k’ numbers of painters are available to paint these boards. Consider that each unit of a board takes 1 unit of time to paint.

You are supposed to return the area of the minimum time to get this job done of painting all the ’n’ boards under the constraint that any painter will only paint the continuous sections of boards.

Example :

Input: arr = [2, 1, 5, 6, 2, 3], k = 2
Output: 11

Try this question!

7. Longest Common Prefix

Write a function to find the longest common prefix string amongst an array of strings.

If there is no common prefix, return an empty string "".

Try this question!

8. Climbing Stairs

You are climbing a staircase. It takes n steps to reach the top.

Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?

Example:

Input: n = 2
Output: 2
Explanation: There are two ways to climb to the top.
1. 1 step + 1 step
2. 2 steps

Try this question!

9. Binary Tree Inorder Traversal

Given the root of a binary tree, return the inorder traversal of its nodes' values.

Try this question!

10. Pascal’s Triangle II

Given an integer rowIndex, return the rowIndexth (0-indexed) row of the Pascal's triangle.

In Pascal’s triangle, each number is the sum of the two numbers directly above it as shown:

pascal triangle
Pascal Triangle

11. Palindrome Number

Given an integer x, return true if x is a palindrome, and false otherwise.

Try this question!

12. Remove Element

Given an integer array nums and an integer val, remove all occurrences of val in nums in-place. The order of the elements may be changed. Then return the number of elements in nums which are not equal to val.

Consider the number of elements in nums which are not equal to val be k, to get accepted, you need to do the following things:

  • Change the array nums such that the first k elements of nums contain the elements which are not equal to val. The remaining elements of nums are not important as well as the size of nums.
  • Return k.

Try this question!

13. Remove Duplicates from Sorted Array

Given an integer array nums sorted in non-decreasing order, remove the duplicates in-place such that each unique element appears only once. The relative order of the elements should be kept the same. Then return the number of unique elements in nums.

Consider the number of unique elements of nums to be k, to get accepted, you need to do the following things:

  • Change the array nums such that the first k elements of nums contain the unique elements in the order they were present in nums initially. The remaining elements of nums are not important as well as the size of nums.
  • Return k.

Try this question!

14. Symmetric Tree

Given the root of a binary tree, check whether it is a mirror of itself (i.e., symmetric around its center).

Try this question!

15. Length of Last Word

Given a string s consisting of words and spaces, return the length of the last word in the string.

A word is a maximal substring consisting of non-space characters only.

Try this question!

So, these are all easy 15 DSA Google Interview questions. Just try these out! Do practice. Then, in the next blog, we will discuss medium-level DSA problems for Google Interview.

All the best!

--

--

Kiran Maan
CodeMinds AI

✦ web developer ✦ MCA in web development ✦ Love to talk about Technology, AI and Programming tips and tricks