Mastercard | Online Assessment | Software Engineer

mastercard logo
mastercard
· Software Engineer· India
September 2, 2026 · 0 reads

Summary

I completed the Mastercard online assessment for a Software Engineer position, which consisted of two hard coding questions.

Full Experience

Status & Timeline

  • Status: Student
  • Position: Software Engineer
  • Location: India
  • Date: September 2026

Overview

  • Platform: HirePro
  • Duration: 60 mins
  • Total Questions: 2 Coding Questions

Question 1: Virus Containment Grid

  • Difficulty: Hard
  • Topics: Matrix BFS/DFS, Simulation, Greedy
  • LeetCode Reference: 749. Contain Virus

Problem Summary

The problem was a direct story-based variant of LeetCode 749 (Contain Virus).

Given a 2D grid representing infected regions (1) and uninfected areas (0), infected cells spread to adjacent cells every turn. You can build quarantine walls to isolate one infected region per turn.

The goal is to determine the minimum number of wall segments needed to permanently contain the spread by greedily quarantining the region that threatens the largest number of uninfected cells at each step.


Question 2: Minimum Trie Nodes with String Permutations

  • Difficulty: Hard
  • Topics: Bitmask DP / Dynamic Programming, String Permutations, Trie, Greedy

Problem Statement

You are given an array of $N$ strings words. You need to construct a Prefix Tree (Trie) to store all $N$ strings. Before inserting the strings into the Trie, you are allowed to independently permute (rearrange) the characters of each string in any order you choose.

Find the minimum total number of nodes (including the root node) required to represent all $N$ strings in the Trie after choosing optimal character orderings for each string.

Constraints

  • $1 \le N \le 16$
  • $1 \le \text{length of } words[i] \le 10^5$
  • All strings consist of lowercase English letters ('a' to 'z').

Sample Test Case

Input: N = 3, words = ["pqr", "qps", "ptr"]
Output: 7

Explanation:
Permute words to: ["pqr", "pqs", "ptr"]
- Root node: 1
- Shared prefix 'p' across all 3 words: 1 node
- Shared prefix 'pq' between word 1 and 2: 1 node
- Unique suffix nodes ('r' for w1, 's' for w2, 'tr' for w3): 4 nodes
Total Nodes = 1 + 1 + 1 + 4 = 7

Interview Questions (2)

1.

Virus Containment Grid

Data Structures & Algorithms·Hard

Given a 2D grid representing infected regions (1) and uninfected areas (0), infected cells spread to adjacent cells each turn. You may build quarantine walls to isolate one infected region per turn. Determine the minimum number of wall segments required to permanently contain the spread by always quarantining the region that threatens the most uninfected cells.

Constraints: Not explicitly provided in the post.

Goal: Compute the minimal total number of walls needed to stop the infection forever.

2.

Minimum Trie Nodes with String Permutations

Data Structures & Algorithms·Hard

You are given an array of $N$ strings words. You may independently permute the characters of each string before inserting them into a Trie. Determine the minimum total number of nodes (including the root) required to store all strings in the Trie after optimal reordering.

Constraints:

  • $1 \le N \le 16$
  • $1 \le \text{length of } words[i] \le 10^5$
  • Strings contain only lowercase English letters.

Example: Input: N = 3, words = ["pqr", "qps", "ptr"] Output: 7 Explanation: By permuting to ["pqr", "pqs", "ptr"] the shared prefixes reduce the node count to 7.

📣 Found this helpful? Please share it with friends who are preparing for interviews!

Discussion (0)

Share your thoughts and ask questions

Join the Discussion

Sign in with Google to share your thoughts and ask questions

No comments yet

Be the first to share your thoughts and start the discussion!