← 返回博客列表
JPMorgan

JP Morgan Chase NAMR SWE Campus 2026 OA Breakdown: Meeting Scheduler + Reduction 3

2026-03-27

JP Morgan Chase OA

The JP Morgan Chase & Co. NAMR Software Engineer Program 2026 campus OA is 60 minutes with two algorithm problems. Here is a full breakdown of both questions with solutions.


Problem 1: Reduction 3 — Array Reduction Total Cost

Problem Statement

Given an array arr of n integers, perform n-1 operations. Each operation removes the current minimum and maximum, appends their sum, and incurs a cost:

cost = ceil((min + max) / (max - min + 1))

Return the total cost to reduce the array to a single element.

Example

arr = [2, 3, 4, 5, 7]:

Step min / max Cost Array Total
1 2, 7 ceil(9/6) = 2 [3,4,5,9] 2
2 3, 9 ceil(12/7) = 2 [4,5,12] 4
3 4, 12 ceil(16/9) = 2 [5,16] 6
4 5, 16 ceil(21/12) = 2 [21] 8

Output: 8

Sample Case 0

Input: arr = [3, 5, 2, 1, 9, 6] → Output: 10

Approach

Each operation requires the global minimum and maximum of the current array. Maintain a sorted structure and insert the new sum in O(log n) per step.

from math import ceil

def findTotalCost(arr):
    arr = sorted(arr)
    total = 0
    while len(arr) > 1:
        mn, mx = arr[0], arr[-1]
        cost = ceil((mn + mx) / (mx - mn + 1))
        total += cost
        arr = arr[1:-1]
        s = mn + mx
        # Binary search insert
        lo, hi = 0, len(arr)
        while lo < hi:
            mid = (lo + hi) // 2
            if arr[mid] < s:
                lo = mid + 1
            else:
                hi = mid
        arr.insert(lo, s)
    return total

Complexity: O(n²) for the naive version; use sortedcontainers.SortedList for O(n log n).

Key Notes


Problem 2: Meeting Scheduler — Minimum Meeting Rooms

Problem Statement

Given n meetings as meetingTimings[i] = [start, end], find the minimum number of rooms needed so no two meetings overlap in the same room.

Note: Meetings can end and start at the same time in one room (e.g. [10,15] and [15,20] can share a room).

Example

meetingTimings = [[1,4],[1,5],[5,6],[6,10],[7,9]]2 rooms

Sample Case 0

Input: [[2,8],[3,9],[5,11],[3,4],[11,15],[8,20]] → Output: 3

Optimal assignment:

Approach

Classic greedy + min-heap (sweep line):

  1. Sort meetings by start time.
  2. Use a min-heap to track the earliest end time among all currently allocated rooms.
  3. For each meeting:
    • If the earliest-ending room finishes at or before the current start time, reuse it (pop and push new end time).
    • Otherwise, open a new room (push new end time).
  4. The heap size is the answer.
import heapq

def getMinRooms(meetingTimings):
    meetings = sorted(meetingTimings, key=lambda x: x[0])
    heap = []  # earliest end times of allocated rooms
    for start, end in meetings:
        if heap and heap[0] <= start:
            heapq.heapreplace(heap, end)
        else:
            heapq.heappush(heap, end)
    return len(heap)

Complexity: O(n log n), dominated by sorting.

Key Notes


Summary

Problem Core Idea Complexity
Reduction 3 Sorted structure, dynamic min/max merge O(n²) / O(n log n)
Meeting Scheduler Sort + min-heap sweep line O(n log n)

Both are textbook greedy/heap problems — very doable within 60 minutes.


💬 Need OA / VO Support?

Ongoing coverage of OA questions from JP Morgan, Goldman Sachs, Citadel, Two Sigma, and more. Feel free to reach out.

WeChat: Coding0201


📬 Contact

Email: [email protected]
Telegram: @OAVOProxy