Top MNC 150 Codes

1. The Shifting Array

Problem Statement:
You are given an array of size N consisting of integers. You need to perform M left circular shifts on the array. After the shifts, print the final state of the array.

Constraints:

Example Input:

N = 5, M = 2
Array = [1, 2, 3, 4, 5]

Example Output:

[3, 4, 5, 1, 2]

Asked in: Google, Microsoft, NVIDIA (2023, 2025)

2. The XOR Puzzle

Problem Statement:
You are given an array of size N. Find the minimum possible XOR of any subset of elements in the array.

Constraints:

Example Input:

N = 3
Array = [3, 5, 10]

Example Output:

2

Asked in: Amazon, Meta, Google (2024)

3. Minimum Insertions for Palindrome

Problem Statement:
Given a string S, find the minimum number of insertions required to make it a palindrome.

Constraints:

Example Input:

S = "abcde"

Example Output:

4  (Palindrome: "abcdedcba")

Asked in: Adobe, Google, Microsoft (2022, 2024)

4. The Kth Smallest Sum of Pairs

Problem Statement:
Given two sorted arrays A and B, find the K-th smallest sum of pairs (A[i] + B[j]).

Constraints:

Example Input:

A = [1, 2, 3]
B = [2, 3, 4]
K = 4

Example Output:

5  (The 4th smallest sum: {3, 4, 4, 5, ...})

Asked in: Facebook, Amazon, Google (2023, 2025)

5. Maximum Profit in Job Scheduling with Deadlines and Profits

Problem Statement:
You are given a list of jobs where each job has a deadline and a profit. You can only schedule one job at a time. Scheduling a job takes one unit of time. Find the maximum total profit that can be earned by scheduling the jobs optimally. Jobs can be scheduled in any order, but each job must be completed before its deadline.

Constraints:

Example Input:

Jobs = [[4, 20], [1, 10], [1, 40], [1, 30]]

Example Output:

70 (Jobs scheduled: [1, 40], [4, 20], [1, 10])

Asked in: Amazon, Facebook, Bloomberg (2022, 2023)

6. Minimum Cost to Connect All Nodes (Steiner Tree Problem)

Problem Statement:
Given a weighted undirected graph and a set of required nodes, find the minimum cost to connect all the required nodes. You can include additional nodes (Steiner nodes) to minimize the total cost. This is a generalization of the minimum spanning tree problem.

Constraints:

Example Input:

    Graph:
    Nodes = {1, 2, 3, 4}
    Edges = [[1, 2, 10], [2, 3, 15], [1, 3, 5], [4, 1, 2], [4, 2, 4]]
    Required nodes = {1, 2, 3}
    

Example Output:

15 (Edges: [1, 3, 5], [1, 2, 10])

Asked in: Google Research, DeepMind, Advanced Algorithms Interviews (2023, 2024)

7. Optimal Resource Allocation with Task Dependencies and Deadlines

Problem Statement:
You are given a set of tasks, each with a processing time, a deadline, and a list of dependencies (other tasks that must be completed before it). You have a limited number of resources. Your goal is to schedule the tasks on the resources to maximize the number of tasks completed before their deadlines. Tasks can be processed in parallel if resources allow, but dependencies must be respected. Find the optimal schedule and the maximum number of tasks completed on time.

Constraints:

Example Input:

    Tasks = [
        {processTime: 5, deadline: 10, dependencies: []},
        {processTime: 3, deadline: 15, dependencies: [0]},
        {processTime: 7, deadline: 20, dependencies: [0]},
        {processTime: 2, deadline: 18, dependencies: [1, 2]},
        {processTime: 4, deadline: 25, dependencies: [3]}
    ]
    Resources = 2
    

Example Output:

5 (All tasks can be completed on time)

Asked in: Specialized Scheduling Algorithm Roles, Advanced System Design (2023, 2024)

🔒 This content is locked. If you want to see the complete solutions, please email us and follow the procedure.