Minimum Processes for Page Origins
Updated
Problem statement
A browser opens one page for every URL in urls. Two pages may share a process only when they have the same origin: the same scheme, the same host, and the same port. Any number of pages with the same origin can share one process.
Every URL has the form scheme://host, optionally followed by :port, optionally followed by a path that starts with /. When the port is missing, it is 80 for http and 443 for https. The path never affects the origin.
Return the minimum number of processes needed to open every page.
Function
minimumProcesses(urls: String[]) → intExamples
Example 1
urls = ["https://shop.example.com/cart","https://shop.example.com/","https://shop.example.com:443/help","http://shop.example.com/cart"]return = 2The first three pages all use https, host shop.example.com, and port 443 (written out in the third URL, filled in by default for the others), so they share one process. The last page uses http on port 80, which is a different origin. The answer is 2.
Example 2
urls = ["http://a.com:8080/x","http://a.com:8081/x","http://b.com:8080/x"]return = 3All three pages differ in port or host, so each needs its own process. The answer is 3.
Example 3
urls = ["http://news.site.org","http://news.site.org:80/today"]return = 1The first URL has no port, so it uses 80, the same port as the second. Both pages share one process, so the answer is 1.
Constraints
1 <= urls.length <= 10^41 <= urls[i].length <= 100- The scheme is
httporhttps. - The host is 1 to 30 characters from lowercase letters, digits,
., and-. - A port, when present, is a number from
1to65535with no leading zeros. - A path, when present, starts with
/and uses only lowercase letters, digits,/,.,_, and-.
More Oracle Phone Screen questions
- Remove Parentheses from a Plus-Minus ExpressionPHONE SCREEN · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · Seen Oct 2026
- Shortest Window by Distinct-Value SumPHONE SCREEN · Seen Oct 2026
- Detect a Cycle in a Directed GraphPHONE SCREEN · Seen Oct 2026
- Time-Based Key-Value StorePHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Remove Adjacent Duplicates in String IIPHONE SCREEN · Seen Oct 2026
- Sum Root-to-Leaf Binary NumbersPHONE SCREEN · Seen Oct 2026
- Longest All-Present Attendance StreakPHONE SCREEN · Seen Oct 2026
- Next PermutationPHONE SCREEN · Seen Sep 2026
- Valid ParenthesesPHONE SCREEN · Seen Sep 2026
Similar questions at other companies
- Transaction Fee Calculator — Parts 1–2: Basic Fee Calculation and Conditional Fee RulesStripe · PHONE SCREENStripe interview questions
- Detect a Straight FlushTemu · PHONE SCREENTemu interview questions
- First Letter to Appear TwiceCisco · PHONE SCREENCisco interview questions
- Halfway Course in a Single TrackCrunchyroll · PHONE SCREENCrunchyroll interview questions
- Single-Condition Product FilterCrowdstrike · PHONE SCREENCrowdstrike interview questions
- Summarize Server Healthcheck LogsNVIDIA · PHONE SCREENNVIDIA interview questions
- Known Words Matching Phone DigitsLinkedIn · PHONE SCREENLinkedIn interview questions
- First Non-Repeated CharacterDell Technologies · PHONE SCREENDell Technologies interview questions
- Convert an Entry List to a MapEPAM · PHONE SCREENEPAM interview questions
- First Non-Repeating CharacterGoldman Sachs · PHONE SCREEN · ONSITE INTERVIEWGoldman Sachs interview questions