Rippling software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.
Question You are building a simplified card game where each player has a hand of cards and the higher-rated hand wins. Each hand contains exactly...
Input: StringQuestion You need to design a logger library for a new application. The design should be able to allow us to easily add future loggers, like a db...
Input: ArrayQuestion You are building a driver payment system for a food delivery company. The accounting team needs to track how much money is owed to drivers...
Input: StringQuestion You need to build a rule evaluation system for a corporate credit card platform. Managers should be able to create rules that enforce...
Input: Listdelivery_cost_units = rate_cents_per_hour * (end - start)Support these operation records:{"op": "register", "driver_id": string, "rate_cents_per_hour": integer}: Register a new driver. Return null.{"op": "record", "driver_id": string, "start": integer, "end": integer}: Record a new, initially unpaid delivery. Return null.{"op": "total"}: Return the cost of all recorded deliveries, including those already paid.{"op": "unpaid"}: Return the cost of all currently unpaid deliveries.{"op": "unpaid_through", "cutoff": integer}: Return the cost of currently unpaid deliveries whose end timestamp is at most cutoff, without changing the ledger.{"op": "pay", "cutoff": integer}: Mark all currently unpaid deliveries whose end timestamp is at most cutoff as paid, and return the amount newly paid by this operation.record operation represents a distinct delivery, even when its fields match an earlier record.Return one result per operation. Your implementation must handle the maximum input size without scanning all deliveries for each query or payment.Function or class signatureprocess_operations(operations: list[dict[str, str | int]]) -> list[int | None][
{"op": "register", "driver_id": "d1", "rate_cents_per_hour": 3600},
{"op": "register", "driver_id": "d2", "rate_cents_per_hour": 7200},
{"op": "record", "driver_id": "d1", "start": 0, "end": 10},
{"op": "record", "driver_id": "d2", "start": 5, "end": 15},
{"op": "total"},
{"op": "unpaid_through", "cutoff": 10},
{"op": "pay", "cutoff": 10},
{"op": "unpaid"},
{"op": "pay", "cutoff": 10},
{"op": "total"}
][null, null, null, null, 108000, 36000, 36000, 72000, 0, 108000]
3600 * 10 = 36000 and 7200 * 10 = 72000 units. Only the first ends at or before timestamp 10. Paying it leaves 72000 units unpaid, and repeating that payment pays zero. Lifetime cost remains 108000 units.Example 2:[
{"op": "register", "driver_id": "d", "rate_cents_per_hour": 1800},
{"op": "record", "driver_id": "d", "start": 20, "end": 40},
{"op": "pay", "cutoff": 100},
{"op": "record", "driver_id": "d", "start": 0, "end": 10},
{"op": "unpaid"},
{"op": "unpaid_through", "cutoff": 5},
{"op": "pay", "cutoff": 10},
{"op": "pay", "cutoff": 100},
{"op": "total"}
][null, null, 36000, null, 18000, 0, 18000, 0, 54000]
1800 * 20 = 36000 units and is paid through timestamp 100. The late-recorded delivery costs 1800 * 10 = 18000 units and is still unpaid. Its end timestamp is 10, so querying through 5 returns zero and paying through 10 settles it. Lifetime cost is 36000 + 18000 = 54000 units.Constraints:0 <= len(operations) <= 200000.1 <= rate_cents_per_hour <= 1000000.0 <= start < end <= 1000000000; cutoffs are integers in [0, 1000000000].O(n log n) total time and O(n) auxiliary space.Scenario
Part 1 — Individual expense rules
id, employee_id, trip_id, category, amount, receipt, and timestamp; amounts are dollar strings such as "50.00", and timestamps are integer Unix seconds encoded as strings.PROHIBITED_CATEGORY: category is exactly "alcohol", regardless of amount.MEAL_LIMIT: category is exactly "meal" and amount is strictly greater than "75.00".RECEIPT_REQUIRED: amount is at least "25.00" and receipt is "no".evaluate_expenses(expenses: list[dict[str, str]])The return type is up to the candidate. The examples use a JSON array of objects containing id and violations; use this representation when verifying the examples.Example 1:
{
"expenses": [
{"id":"e1","employee_id":"u1","trip_id":"t1","category":"meal","amount":"75.00","receipt":"yes","timestamp":"0"},
{"id":"e2","employee_id":"u1","trip_id":"t1","category":"meal","amount":"75.01","receipt":"yes","timestamp":"1"},
{"id":"e3","employee_id":"u1","trip_id":"t1","category":"alcohol","amount":"10.00","receipt":"no","timestamp":"2"},
{"id":"e4","employee_id":"u1","trip_id":"t1","category":"taxi","amount":"25.00","receipt":"no","timestamp":"3"},
{"id":"e5","employee_id":"u1","trip_id":"t1","category":"entertainment","amount":"200.00","receipt":"yes","timestamp":"4"}
]
}[
{"id":"e1","violations":[]},
{"id":"e2","violations":["MEAL_LIMIT"]},
{"id":"e3","violations":["PROHIBITED_CATEGORY"]},
{"id":"e4","violations":["RECEIPT_REQUIRED"]},
{"id":"e5","violations":[]}
]Part 2 — Cross-expense policy rules
evaluate_policy(expenses: list[dict[str, str]]) with these requirements:TRIP_BUDGET: Sum all expenses for each trip_id. If the total is strictly greater than $1,000.00, emit one trip-level finding with trip_id, rule, total, limit, and expense_ids. Include all of that trip's expense IDs in input order. Do not duplicate this trip-level code onto individual expenses. Sort trip findings lexicographically by trip_id; format monetary totals with exactly two decimal places.ENTERTAINMENT_24H: For each entertainment expense at timestamp t, sum that employee's entertainment expenses across all trips with timestamps in (t - 86400, t]. If the sum is strictly greater than $200.00, add this code to that expense's violations. Other categories do not receive this code.expenses and trip_violations.Example 2:
{
"expenses": [
{"id":"a1","employee_id":"u1","trip_id":"t1","category":"entertainment","amount":"120.00","receipt":"yes","timestamp":"0"},
{"id":"a2","employee_id":"u1","trip_id":"t2","category":"entertainment","amount":"90.00","receipt":"yes","timestamp":"3600"},
{"id":"a3","employee_id":"u1","trip_id":"t1","category":"hotel","amount":"800.00","receipt":"yes","timestamp":"4000"},
{"id":"a4","employee_id":"u1","trip_id":"t1","category":"taxi","amount":"100.00","receipt":"yes","timestamp":"5000"},
{"id":"a5","employee_id":"u2","trip_id":"t3","category":"entertainment","amount":"200.00","receipt":"yes","timestamp":"3600"}
]
}{
"expenses": [
{"id":"a1","violations":[]},
{"id":"a2","violations":["ENTERTAINMENT_24H"]},
{"id":"a3","violations":[]},
{"id":"a4","violations":[]},
{"id":"a5","violations":[]}
],
"trip_violations": [
{"trip_id":"t1","rule":"TRIP_BUDGET","total":"1020.00","limit":"1000.00","expense_ids":["a1","a3","a4"]}
]
}a1, u1's entertainment total is $120.00. At a2, it is $120.00 + $90.00 = $210.00, so a2 violates the rolling cap even though the expenses belong to different trips. Employee u2 has a separate total of exactly $200.00, which is allowed. Trip t1 totals $120.00 + $800.00 + $100.00 = $1,020.00; trips t2 and t3 total $90.00 and $200.00.Example 3:
{
"expenses": [
{"id":"b1","employee_id":"u1","trip_id":"tA","category":"entertainment","amount":"100.00","receipt":"yes","timestamp":"0"},
{"id":"b3","employee_id":"u1","trip_id":"tB","category":"entertainment","amount":"100.00","receipt":"no","timestamp":"86400"},
{"id":"b2","employee_id":"u1","trip_id":"tA","category":"entertainment","amount":"110.00","receipt":"yes","timestamp":"86400"},
{"id":"b4","employee_id":"u1","trip_id":"tB","category":"entertainment","amount":"0.01","receipt":"yes","timestamp":"86401"},
{"id":"b5","employee_id":"u1","trip_id":"tA","category":"hotel","amount":"790.00","receipt":"yes","timestamp":"86402"}
]
}{
"expenses": [
{"id":"b1","violations":[]},
{"id":"b3","violations":["ENTERTAINMENT_24H","RECEIPT_REQUIRED"]},
{"id":"b2","violations":["ENTERTAINMENT_24H"]},
{"id":"b4","violations":["ENTERTAINMENT_24H"]},
{"id":"b5","violations":[]}
],
"trip_violations": []
}b1 is exactly 86400 seconds old and is excluded. Both same-timestamp records see $100.00 + $110.00 = $210.00, so both violate the entertainment cap. b3 also lacks a required receipt, but still contributes to the sum. At timestamp 86401, the entertainment total is $210.01. Trip tA totals $100.00 + $110.00 + $790.00 = $1,000.00 exactly, so it does not violate the trip budget; tB totals $100.01.Notes:
"yes" or "no"."1000000.00". Timestamps are integer strings between 0 and 10^12 inclusive.[] in Part 1 and {"expenses":[],"trip_violations":[]} in Part 2.startNode to an endNode such that the total weight does not exceed a given weightLimit. If no such path exists, return None. def shortest_path_with_weight_limit(graph: Dict[str, List[Tuple[str, int]]], startNode: str, endNode: str, weightLimit: int) -> Optional[List[str]]: graph = {'A': [('B', 5), ('C', 10)], 'B': [('C', 2)], 'C': []}, startNode = 'A', endNode = 'C', weightLimit = 8 ['A', 'B', 'C'] graph = {'A': [('B', 5), ('C', 10)], 'B': [('C', 2)], 'C': []}, startNode = 'A', endNode = 'C', weightLimit = 6 None 10^5 nodes. 1 to 100. 500. cost of size n where cost[i] represents the cost of hiring the i-th employee. You can hire employees in blocks (consecutive hires). Since hiring costs may vary, you want to determine the minimum total cost to hire all the employees. Implement a function min_cost(cost: List[int]) -> int that returns this minimum cost.def min_cost(cost: List[int]) -> int:cost = [10, 20, 30] 60 cost = [10, 30, 20, 40] 100 1 <= cost.length <= 1000 1 <= cost[i] <= 1000 AttendanceSystem that tracks employee attendance. The class should support methods to mark attendance, check if an employee was present on a given day, and get the total attendance count for an employee. Each employee is identified by a unique employee ID.Function/class signature: def __init__(self): def mark_attendance(self, employee_id: int, date: str) -> None: def was_present(self, employee_id: int, date: str) -> bool: def total_attendance(self, employee_id: int) -> int: mark_attendance(1, "2023-10-01") was_present(1, "2023-10-01") employee_id is a positive integer. date is formatted as "YYYY-MM-DD" and represents valid dates only. def longest_consecutive(nums: List[int]) -> int:[100, 4, 200, 1, 3, 2] 4 [1, 2, 3, 4], which has a length of 4.[1, 2, 0, 1] 3 [0, 1, 2], with a length of 3.0 <= len(nums) <= 10^5 -10^9 <= nums[i] <= 10^9minBenefitsCost(int start, List<List<int>> benefitsGraph) -> int - returns the minimum cost to connect all benefits.start = 0, benefitsGraph = [[0, 5, 10], [5, 0, 3], [10, 3, 0]]8start = 1, benefitsGraph = [[0, 2], [2, 0]]21 ≤ benefitsGraph.length ≤ 10001 ≤ benefitsGraph[i][j] ≤ 10^4longestSubarray(int[] productivity, int threshold) -> int - returns the length of the longest subarray where average productivity <= threshold.[1, 2, 3, 4, 2, 3], threshold = 34[1, 2, 3, 4].Example 2:[5, 1, 3, 2, 5, 4], threshold = 33[1, 3, 2].Constraints:1 ≤ productivity.length ≤ 10^61 ≤ productivity[i] ≤ 1001 ≤ threshold ≤ 100def min_cost_path(graph: Dict[int, List[Tuple[int, int]]], start: int, end: int) -> int{0: [(1, 5), (2, 10)], 1: [(3, 2)], 2: [(3, 1)], 3: []}, 0, 375 + 2 = 7.Constraints:1 <= len(graph) <= 100010 entries.def max_compliance_score(transactions: List[int]) -> int[10, 20, 15, 25, 30]6010, 20, and 30, leading to a total of 60.Example 2:[5, 1, 2, 10]155 and 10 yield the highest score of 15.Constraints:1 <= len(transactions) <= 10001 <= transactions[i] <= 10000Sign up for free to access walkthroughs, AI-generated questions, and more.
Get Started Free