Skip to main content

Command Palette

Search for a command to run...

Top 3 Deloitte Coding Interview Questions from 2025

Updated
3 min read

Introduction

In this blog post, we'll share the most commonly asked coding interview questions at Deloitte. If you don't have months to study for your interviews, you can use AI tools like Chatmagic to generate solutions quickly and efficiently - helping you pass the interviews and get the job offer!

Problem #1: Second Highest Salary

Table: Employee +-------------+------+ | Column Name | Type | +-------------+------+ | id | int | | salary | int | +-------------+------+ id is the primary key (column with unique values) for this table. Each row of this table contains information about the salary of an employee. Write a solution to find the second highest distinct salary from the Employee table. If there is no second highest salary, return null (return None in Pandas). The result format is in the following example. Example 1: Input: Employee table: +----+--------+ | id | salary | +----+--------+ | 1 | 100 | | 2 | 200 | | 3 | 300 | +----+--------+ Output: +---------------------+ | SecondHighestSalary | +---------------------+ | 200 | +---------------------+ Example 2: Input: Employee table: +----+--------+ | id | salary | +----+--------+ | 1 | 100 | +----+--------+ Output: +---------------------+ | SecondHighestSalary | +---------------------+ | null | +---------------------+

Topics: Database

Problem #2: 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 "". Example 1: Input: strs = ["flower","flow","flight"] Output: "fl" Example 2: Input: strs = ["dog","racecar","car"] Output: "" Explanation: There is no common prefix among the input strings. Constraints: 1 <= strs.length <= 200 0 <= strs[i].length <= 200 strs[i] consists of only lowercase English letters if it is non-empty.

Topics: String, Trie

Problem #3: Minimum Time to Repair Cars

You are given an integer array ranks representing the ranks of some mechanics. ranksi is the rank of the ith mechanic. A mechanic with a rank r can repair n cars in r n2 minutes. You are also given an integer cars representing the total number of cars waiting in the garage to be repaired. Return the minimum time taken to repair all the cars. Note: All the mechanics can repair the cars simultaneously. Example 1: Input: ranks = [4,2,3,1], cars = 10 Output: 16 Explanation: - The first mechanic will repair two cars. The time required is 4 2 2 = 16 minutes. - The second mechanic will repair two cars. The time required is 2 2 2 = 8 minutes. - The third mechanic will repair two cars. The time required is 3 2 2 = 12 minutes. - The fourth mechanic will repair four cars. The time required is 1 4 4 = 16 minutes. It can be proved that the cars cannot be repaired in less than 16 minutes.​​​​​ Example 2: Input: ranks = [5,1,8], cars = 6 Output: 16 Explanation: - The first mechanic will repair one car. The time required is 5 1 1 = 5 minutes. - The second mechanic will repair four cars. The time required is 1 4 4 = 16 minutes. - The third mechanic will repair one car. The time required is 8 1 * 1 = 8 minutes. It can be proved that the cars cannot be repaired in less than 16 minutes.​​​​​ Constraints: 1 <= ranks.length <= 105 1 <= ranks[i] <= 100 1 <= cars <= 106

Topics: Array, Binary Search

More from this blog

C

Chatmagic blog

2894 posts