Category: String coding problemDesign an article ranking system for a news platform. The system stores articles identified by a unique integer ID, a relevance score, and a category...Input: List Output: Array
codingMediumVerified Question#2
2. Audit Log Analyzer
Category: Graph coding problemDesign an audit log analyzer for a financial transactions platform. The system is initialized with a list of log entries, where each entry is a...Input: Graph (nodes and edges) Output: Computed result
codingHardVerified Question#3
3. Compressed Grid Operations
Category: Matrix coding problemDesign a CompressedGrid class that stores a sparse integer matrix efficiently by keeping only non-zero values in memory. The class must support...Input: Matrix (2D array) Output: Computed result
codingMediumVerified Question#4
4. Coworking Desk Availability
Category: Interval-based coding problemA co-working space manages desk reservations throughout the day. Given the space's operating hours, its total desk capacity, and a list of bookings,...Input: List Output: Array
codingMediumVerified Question#5
5. Degrees of Separation
Category: Algorithm coding problemIn a social network, there are n users numbered from 0 to n - 1. You are given a list of bidirectional friend connections connections, where...Input: List Output: Integer
codingMediumVerified Question#6
6. Directory Permission Manager
Category: Tree coding problemDesign a permission management system for a hierarchical file system. Implement the DirectoryPermissionManager class. The directory hierarchy is...Input: List Output: Computed result
codingMediumVerified Question#7
7. EV Charging Optimizer
Category: Binary search coding problemAn electric vehicle travels along a highway between a start and a destination. Charging stations are located at positions given in a non-decreasing...Input: Array Output: Computed result
codingMediumVerified Question#8
8. Game Level Tracker
Category: String coding problemDesign a leaderboard system for a mobile game where players progress through levels sequentially. Implement the GameLevelTracker class. The game...Input: String Output: Integer
codingMediumVerified Question#9
9. Maximum Meeting Schedule
Category: Algorithm coding problemYou manage a single conference room and have a list of meeting requests. Each meeting is defined by a [start, end] pair. Two meetings overlap if...Input: List Output: Integer
codingMediumVerified Question#10
10. Playlist Song Connection
Category: Graph coding problemA music platform organizes songs into playlists. Each playlist contains a set of distinct song IDs, and a song may appear in multiple playlists. Two...Input: Graph (nodes and edges) Output: Integer
codingMediumVerified Question#11
11. Request Anomaly Linker
Category: Trie-based coding problemYou are building an anomaly detection system for a distributed platform. The system receives request logs and anomaly reports, and must link each...Input: Array of strings Output: Array
codingHardVerified Question#12
12. Run Length Decode All
Category: Graph coding problemA signal log is compressed using run-length encoding. In this scheme, a source string of digits is scanned left to right, and each run of identical...Input: Graph (nodes and edges) Output: Array
codingMediumVerified Question#13
13. Timed Job Queue
Category: Priority queue coding problemDesign a background job scheduling system called TimedJobQueue. The system accepts jobs with an associated delay and executes them in delay order....Input: List Output: Array
codingMediumVerified Question#14
14. Unordered Nested Equality
Category: String coding problemTwo configurations are considered equal if they contain the same elements regardless of order at every level of nesting. Elements can be atomic...Input: List Output: Computed result
codingMediumVerified Question#15
15. Warehouse Drone Dispatch
Category: String coding problemA vertical warehouse uses autonomous drones to fulfill package requests. Each drone is at a specific floor and has one of three states:...Input: List Output: Integer
codingMediumVerified Question#16
16. Warehouse Item Counter
Category: Grid/matrix coding problemYou are building a warehouse inventory scanner that analyzes a 2D grid representing a warehouse floor. Each cell is either 'X' (part of an item) or...Input: 2D grid Output: Computed result
codingMediumdynamic programming#1
1. Dynamic Programming — Split Array for Largest Sum
Background: In Pinterest, handling user-generated content is critical to ensuring smooth performance. When grouping content into arrays based on collective engagement, it is important to optimize resource consumption during this process. Problem statement: Given an array nums of non-negative integers, partition it into m non-empty contiguous subarrays. The task is to minimize the largest sum among these subarrays. For example, if nums = [7, 2, 5, 10, 8] and m = 2, the partitioning could be [7,2] and [5,10,8], resulting in a largest sum of 18. Function/class signature:
def split_array(nums: List[int], m: int) -> int:
Example 1: Input: nums = [7, 2, 5, 10, 8], m = 2 Output: 18 Explanation: One optimal solution is to split the array into [7,2] and [5,10,8]. The largest sum is 18.Example 2: Input: nums = [1, 4, 4], m = 3 Output: 4 Explanation: Split into [1], [4], [4], hence the largest sum is 4.Constraints:
Background: In Pinterest, users can save various travel ideas including destinations and routes. Efficiently organizing and reconstructing these routes from a set of unordered flight tickets is crucial for building features like travel boards. Problem statement: You are given an array of tickets where each ticket is represented as a pair of strings ['Origin', 'Destination']. You need to reconstruct the itinerary in order of visits starting from 'JFK' and visiting each destination exactly once. The answer should be in lexicographically smallest order if there are multiple valid itineraries. Return the reconstructed itinerary as a list of strings. Function/class signature:
Example 1: Input: [['MUC', 'LHR'], ['JFK', 'MUC'], ['SFO', 'SJC'], ['LHR', 'SFO']] Output: ['JFK', 'MUC', 'LHR', 'SFO', 'SJC'] Explanation: Starting from 'JFK', the only path using all tickets is 'JFK' → 'MUC' → 'LHR' → 'SFO' → 'SJC'. Example 2: Input: [['JFK', 'SFO'], ['JFK', 'ATL'], ['ATL', 'JFK'], ['SFO', 'ATL']] Output: ['JFK', 'ATL', 'JFK', 'SFO'] Constraints:
1 <= tickets.length <= 1000
Each ticket is a non-empty pair of strings with length <= 3
All Origin and Destination strings consist of uppercase English letters only.
codingMediumgraph#3
3. [Graph] — Reconstruct routes from unordered travel tickets
Background: Pinterest enables users to share travel inspirations and itineraries through boards. When users share travel tickets, reconstructing the ordered trip route enhances usability and improves user experience. Problem statement: You are given a list of tickets, where each ticket is a pair of departure and arrival airports represented as strings. The tickets may not be in any specific order. Your task is to reconstruct the itinerary in the order of travel. The itinerary must start from 'JFK'. Return a list of strings representing the route. If no such itinerary exists, return an empty list. Note that there may be multiple valid itineraries, but you should return the one that uses the smallest lexical order. Function/class signature:
Airports are represented by capital letters and can have up to 10 characters each.
codingMediumgraph#4
4. Graph — Reconstruct Travel Routes
Background: Pinterest connects users through shared interests, and travel ideas often come from various sources. Reconstructing users' travel routes from unordered tickets can help provide enhanced recommendations and visualizations. Problem statement: You are given a list of unordered travel tickets represented as pairs of departure and arrival airports. Your task is to reconstruct the itinerary based on the tickets and return it in order. You may assume that the provided tickets are such that there is exactly one valid itinerary without cycles. Use depth-first search to find the route. The resulting route must start from JFK. Function/class signature:
Explanation: The route allows to return to JFK from ATL using available tickets.
Constraints:
1 <= len(tickets) <= 1000
Each ticket is represented by a pair of strings: from and to airport codes.
Each airport code consists of 3 uppercase letters.
codingMediumgraph#5
5. [Graph] — Reconstruct Route from Unordered Travel Tickets
Background: Pinterest often encourages travel and exploration of interests through its platform. Efficient route mapping can enhance user experiences related to travel pins and recommendations. Problem statement: Given a list of unordered travel tickets represented as pairs of strings, where each pair (from, to) indicates a direct ticket from from to to, reconstruct the route in the correct order starting from the initial city. You must return a list of cities in the correct order.Function/class signature:
Background: In Pinterest's visual discovery platform, users can curate and search through a vast number of images, each representing various interests. A feature to suggest the most relevant trends or categories could greatly enhance user engagement. Finding the longest increasing subsequence of interests can help in generating recommended content. Problem statement: Given an array of integers representing user interests, where each integer corresponds to a unique identifier for an interest, your task is to find the length of the longest increasing subsequence of these interests. The interests can be thought of as items in a feed whose engagement counts are being tracked. Function/class signature: