Mastercard | Online Assessment | Software Engineer

Anonymous User
330
Sep 02, 2026

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 strings words. You need to construct a Prefix Tree (Trie) to store all 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 strings in the Trie after choosing optimal character orderings for each string.

Constraints

  • 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

Comments (3)