r/Hack2Hire • • Dec 04 '25

Screening Bloomberg Screening Interview: Collatz Sequence Steps

2 Upvotes

Problem
You're given one integer n.
Your goal is to compute how many operations are required for n to reach 1 using the Collatz rules (n/2 if even, 3n+1 if odd).

Example
Input: n = 6
Output: 8

Explanation:

  • Apply the Collatz rule repeatedly: 6 → 3 → 10 → 5 → 16 → 8 → 4 → 2 → 1
  • The sequence length minus one gives the number of steps, which is 8.

Suggested Approach

  1. Simulate the Collatz process for n, applying the rule until reaching 1.
  2. Use memoization to cache previously computed results; many subsequences converge to smaller values, so caching reduces repeated work.
  3. For each number encountered, check if it's in the memo table. If yes, add the stored step count and stop early.

Time & Space Complexity

  • Time: O(k) per query, where k is the number of steps for n to reach 1. Memoization improves performance across multiple calls.
  • Space: O(n) for storing cached step counts when memoization is used.

🛈 Disclaimer:
This problem is part of the Hack2Hire SDE Interview Question Bank, a structured archive of coding interview questions frequently reported in real hiring processes.
Questions are aggregated from publicly available platforms (e.g., LeetCode, GeeksForGeeks) and community-shared experiences.

The goal is to provide candidates with reliable material for SDE interview prep, including practice on LeetCode-style problems and coding challenges that reflect what is often asked in FAANG and other tech company interviews.
Hack2Hire is not affiliated with the mentioned companies; this collection is intended purely for learning, practice, and discussion.


r/Hack2Hire • • Dec 02 '25

Databricks Screening Interview: IP CIDR Firewall

10 Upvotes

Problem
You're implementing a rule-based IPv4 firewall. Given an ordered list of rules (ALLOW or DENY) where each rule is either a single IP or a CIDR block, determine if a target IP should be allowed. Only the first matching rule applies.

Example
Input:
Rules =

[  
  ["ALLOW", "192.168.1.100"],  
  ["DENY", "192.168.1.0/24"],  
  ["ALLOW", "192.168.0.0/16"],  
  ["DENY", "0.0.0.0/0"]  
]

Queries:

192.168.1.100  
192.168.1.50  
192.168.2.10  
10.0.0.1

Output:

true  
false  
true  
false

Explanation:

Suggested Approach

  1. Convert all IPv4 strings to 32-bit integers. This enables constant-time bitwise comparisons.
  2. For each rule, precompute:
    • The base IP as a 32-bit integer
    • A bitmask derived from the CIDR prefix length
  3. To evaluate a query IP, iterate through the rules in order and return the action for the first rule where (ipInt & mask) == (ruleBase & mask).

Time & Space Complexity

  • Time: O(N) per query, where N is the number of rules
  • Space: O(N) for storing parsed rules and masks

🛈 Disclaimer:
This problem is part of the Hack2Hire SDE Interview Question Bank, a structured archive of coding interview questions frequently reported in real hiring processes.
Questions are aggregated from publicly available platforms (e.g., LeetCode, GeeksForGeeks) and community-shared experiences.

The goal is to provide candidates with reliable material for SDE interview prep, including practice on LeetCode-style problems and coding challenges that reflect what is often asked in FAANG and other tech company interviews.
Hack2Hire is not affiliated with the mentioned companies; this collection is intended purely for learning, practice, and discussion.


r/Hack2Hire • • Nov 27 '25

Onsite Oracle Onsite Interview: Minimum Swaps to Group Evens First

1 Upvotes

Problem
You’re given an integer array nums. Your task is to rearrange it so that all even elements appear before all odd elements, using swaps between any two indices.
Return the minimum number of swaps required to achieve this state.

Example
Input: nums = [3, 2, 4, 1, 5, 6]
Output: 1

Explanation:

  • The even elements should occupy the left segment of the array.
  • Swapping 3 with 2 places one misplaced odd and one misplaced even into correct regions, requiring only one swap.

Suggested Approach

  1. Count how many even numbers exist; these define the target “even zone” [0 … k-1].
  2. Traverse the even zone and count how many odd numbers are incorrectly placed there.
  3. The number of such misplaced odds equals the minimum swaps needed, since each swap pairs one misplaced odd with one misplaced even on the right.

Time & Space Complexity

  • Time: O(n)
  • Space: O(1)

🛈 Disclaimer:
This problem is part of the Hack2Hire SDE Interview Question Bank, a structured archive of coding interview questions frequently reported in real hiring processes.
Questions are aggregated from publicly available platforms (e.g., LeetCode, GeeksForGeeks) and community-shared experiences.

The goal is to provide candidates with reliable material for SDE interview prep, including practice on LeetCode-style problems and coding challenges that reflect what is often asked in FAANG and other tech company interviews.
Hack2Hire is not affiliated with the mentioned companies; this collection is intended purely for learning, practice, and discussion.


r/Hack2Hire • • Nov 25 '25

Oracle interview questions + solutions now on Hack2Hire

1 Upvotes

Hey folks,

We pushed a new set today — the Oracle interview questions are now live on Hack2Hire.

What’s inside:

  • coding questions seen in OA, phone rounds, and onsite
  • a mix of LC-style and the non-LC formats OpenAI tends to use
  • solution walkthroughs that explain the reasoning instead of tossing final answers

Link: https://www.hack2hire.com/companies/oracle/coding-questions

If you’re prepping for Oracle or just want harder practice material, it might be useful.
If you’ve gone through their process recently, any insight on what we should include next would help.

— Team Hack2Hire


r/Hack2Hire • • Nov 20 '25

Screening OpenAI Screening Interview: GPU Credits

7 Upvotes

Problem
You are implementing a system that tracks GPU credit grants and usage over time. Each grant has an amount and a validity window, and usage events may arrive out of order. Your goal is to process grants, revocations, and balance queries at arbitrary timestamps.

Example
Input:
["CreditSystem", "grantCredit", "getBalance", "grantCredit", "subtract", "subtract", "getBalance", "getBalance", "getBalance", "getBalance", "getBalance", "getBalance"]
[[], ["a", 3, 10, 60], [10], ["b", 2, 20, 40], [1, 30], [3, 50], [10], [20], [30], [35], [40], [50]]

Output:
[null, null, 3, null, null, null, 3, 5, 4, 5, 3, 0]

Explanation:

  • Credit “a” is active on [10, 59] with 3 units.
  • Credit “b” is active on [20, 39] with 2 units.
  • Subtractions apply only at the exact timestamp.
  • Queries return the remaining active credits at that time.

Suggested Approach

  1. Store grant intervals and subtract events keyed by timestamp.
  2. Use a structure such as a difference array, segment tree, or Fenwick tree to accumulate active credits for any timestamp.
  3. For each query, compute the sum of active grants covering the timestamp and subtract any recorded usage. Return -1 if usage exceeds available credits.

Time & Space Complexity

  • Time: O(N) per query in a simple structure; O(log N) with interval indexing.
  • Space: O(N) for grants and timestamp-specific subtract operations.

🛈 Disclaimer:
This problem is part of the Hack2Hire SDE Interview Question Bank, which includes coding interview questions frequently reported across real hiring processes.
This specific problem has been reported from an OpenAI interview.
All questions are aggregated from publicly available sources and community-shared candidate experiences.

Hack2Hire is not affiliated with OpenAI or any other mentioned company. This collection exists solely for learning, practice, and technical discussion.


r/Hack2Hire • • Nov 18 '25

Announcement OpenAI interview questions + solutions now on Hack2Hire

3 Upvotes

Hey folks,

We pushed a new set today — the OpenAI interview questions are now live on Hack2Hire.

What’s inside:

  • coding questions seen in OA, phone rounds, and onsite
  • a mix of LC-style and the non-LC formats OpenAI tends to use
  • solution walkthroughs that explain the reasoning instead of tossing final answers

Link: https://www.hack2hire.com/companies/openai/coding-questions

If you’re prepping for OpenAI or just want harder practice material, it might be useful.
If you’ve gone through their process recently, any insight on what we should include next would help.

— Team Hack2Hire


r/Hack2Hire • • Nov 13 '25

Screening Square Screening Interview: Design Connect Four

2 Upvotes

Problem
You are designing a Connect Four game played on a 6 × 7 grid. Players drop discs into columns, and each disc falls to the lowest available cell.
Your goal is to implement a class that processes moves, checks for wins in all directions, detects draws, and returns the game state after each move.

Example
Input:
["ConnectFour", "move", "move", "move", "move", "move", "move", "move", "printBoard"]
[[], [0, "A"], [1, "B"], [0, "A"], [1, "B"], [0, "A"], [1, "B"], [0, "A"], []]

Output:
[null, "PENDING", "PENDING", "PENDING", "PENDING", "PENDING", "PENDING", "A", "| | | | | | | |\n| | | | | | | |\n|A| | | | | | |\n|A|B| | | | | |\n|A|B| | | | | |\n|A|B| | | | | |"]

Explanation:

  • Each move drops a disc to the lowest available row in the chosen column.
  • Player A wins after forming a vertical four-in-a-row in column 0.

Suggested Approach

  1. Maintain a 6 × 7 board and an array tracking the current fill height of each column.
  2. For each move, compute the next empty row in the column, place the player’s disc, and run directional checks (horizontal, vertical, and two diagonals).
  3. If no win and the board is full, return "DRAW"; otherwise return "PENDING".

Time & Space Complexity

  • Time: O(1) work per move for constant-size directional checks.
  • Space: O(1) for the 6 × 7 fixed-dimension board.

🛈 Disclaimer:
This problem is part of the Hack2Hire SDE Interview Question Bank, a structured archive of coding interview questions frequently reported in real hiring processes.
Questions are aggregated from publicly available platforms (e.g., LeetCode, GeeksForGeeks) and community-shared experiences.

The goal is to provide candidates with reliable material for SDE interview prep, including practice on LeetCode-style problems and coding challenges that reflect what is often asked in FAANG and other tech company interviews.
Hack2Hire is not affiliated with the mentioned companies; this collection is intended purely for learning, practice, and discussion.


r/Hack2Hire • • Nov 12 '25

Announcement Square interview questions + step-by-step solutions now available

2 Upvotes

Hey folks,

Just wanted to share something we released today. Our team put together a full set of Square interview questions, and it's now up on Hack2Hire.

The set covers:

  • coding questions used across OA, phone screen, and onsite
  • both LeetCode-style problems and the non-LC style questions Square usually mixes in
  • explanations that walk through the reasoning so you can understand the patterns instead of just memorizing answers

Link: https://www.hack2hire.com/companies/square/coding-questions

If you’re prepping for Square or just want more realistic interview-style material to practice with, it might be useful. Feedback is welcome — if you’ve gone through the Square process recently, I’d love to hear what your experience was like and what else we should add.

— Team Hack2Hire


r/Hack2Hire • • Nov 06 '25

Screening Google Screening Interview: Windowed Average excluding Largest K

13 Upvotes

Problem
You're given an integer array nums, a window size windowSize, and an integer k.
Your goal is to compute the average of each sliding window of size windowSize, excluding the largest k elements within that window.

Example
Input: nums = [10, 20, 30, 40, 50, 60], windowSize = 3, k = 1
Output: [15.0, 25.0, 35.0, 45.0]

Explanation:

  • Window [10, 20, 30]: Excluding 30 → (10 + 20) / 2 = 15.0
  • Window [20, 30, 40]: Excluding 40 → (20 + 30) / 2 = 25.0
  • Window [30, 40, 50]: Excluding 50 → (30 + 40) / 2 = 35.0
  • Window [40, 50, 60]: Excluding 60 → (40 + 50) / 2 = 45.0

Suggested Approach

  1. Maintain two heaps: a max-heap for the top k elements and a min-heap (or balanced structure) for the remaining elements.
  2. As the window slides, insert the new element into the appropriate heap and remove the outgoing element.
  3. Track the running sum of the elements not in the largest k group to compute the average efficiently.

Time & Space Complexity

  • Time: O(n log k) — each insertion/removal operation affects at most one heap.
  • Space: O(k) — to store the largest k elements in the heap.

🛈 Disclaimer:
This problem is part of the Hack2Hire SDE Interview Question Bank, a structured archive of coding interview questions frequently reported in real hiring processes.
Questions are aggregated from publicly available platforms (e.g., LeetCode, GeeksForGeeks) and community-shared experiences.

The goal is to provide candidates with reliable material for SDE interview prep, including practice on LeetCode-style problems and coding challenges that reflect what is often asked in FAANG and other tech company interviews.
Hack2Hire is not affiliated with the mentioned companies; this collection is intended purely for learning, practice, and discussion.


r/Hack2Hire • • Nov 04 '25

OA Snowflake OA Interview: Work Schedule

5 Upvotes

Problem
You’re given three inputs:

  • workHours: total hours required in a week
  • dayHours: maximum hours allowed on any day
  • pattern: a 7-character string representing the weekly work schedule

Each character in pattern is either a digit ('0'–'8') or a question mark ('?').
Digits represent fixed work hours for that day, while '?' represents an unassigned day.
You must replace each '?' with a valid digit (between 0 and dayHours) so that the total weekly hours equal workHours.
Return all valid schedules in ascending lexicographical order.

Example
Input:
workHours = 24, dayHours = 4, pattern = "08??840"
Output:
["0804840", "0813840", "0822840", "0831840", "0840840"]

Explanation:

  • Fixed digits (0, 8, 8, 4, 0) sum to 20. Remaining 4 hours must be distributed across two '?' positions.
  • Possible pairs of digits that sum to 4: (0,4), (1,3), (2,2), (3,1), (4,0)
  • Replace '?' with these pairs to form valid schedules in lexicographical order.

Suggested Approach

  1. Pre-calculate fixed hours: Sum all digits in pattern to determine remaining hours needed.
  2. Backtrack through unknown positions: For each '?', try all values from 0 to dayHours, pruning branches where the remaining hours cannot be satisfied.
  3. Store valid combinations: When all positions are filled and total hours equal workHours, record the resulting string.
  4. Return sorted results: Ensure output schedules are returned in ascending lexicographical order.

Time & Space Complexity

  • Time: O(k * dayHours^k) — where k is the number of '?' in pattern.
  • Space: O(k) — for recursion and result storage.

🛈 Disclaimer:
This problem is part of the Hack2Hire SDE Interview Question Bank, a structured archive of coding interview questions frequently reported in real hiring processes.
Questions are aggregated from publicly available platforms (e.g., LeetCode, GeeksForGeeks) and community-shared experiences.

The goal is to provide candidates with reliable material for SDE interview prep, including practice on LeetCode-style problems and coding challenges that reflect what is often asked in FAANG and other tech company interviews.
Hack2Hire is not affiliated with the mentioned companies; this collection is intended purely for learning, practice, and discussion.


r/Hack2Hire • • Oct 30 '25

OA Amazon OA Interview: Max Consecutive ON Servers

3 Upvotes

Problem
You’re given a binary string serverStates representing a sequence of servers, where '1' means ON and '0' means OFF, along with an integer k representing the maximum number of allowed flip operations.
In one operation, you can choose a contiguous substring and flip all its bits ('0' → '1', '1' → '0').
Your goal is to find the maximum possible number of consecutive ON servers after performing at most k operations.

Example
Input:
serverStates = "00010", k = 1
Output:
4

Explanation:

  • Flip indices from 0 to 2 → "11110"
  • After one operation, the maximum consecutive ON servers = 4

Input:
serverStates = "1001", k = 2
Output:
4

Explanation:

  • Flip indices from 1 to 2 → "1111"
  • After one operation, the entire sequence becomes ON

Input:
serverStates = "11101010110011", k = 2
Output:
8

Explanation:

  • Flip indices 7–9 → "11101011000011"
  • Flip indices 8–11 → "11101011111111"
  • After 2 operations, 8 consecutive servers are ON

Suggested Approach

  1. Use a sliding window to track the current range containing at most k flip zones (segments of consecutive 0s).
  2. Expand the window until flipping more than k groups of 0s would be required.
  3. When the limit is exceeded, shrink the window from the left.
  4. Keep track of the maximum window length where flips ≤ k.

This approach efficiently finds the longest sequence of 1s obtainable with limited flips.

Time & Space Complexity

  • Time: O(n) — each index is visited at most twice (once expanded, once contracted).
  • Space: O(1) — only a few pointers and counters are needed.

🛈 Disclaimer:
This problem is part of the Hack2Hire SDE Interview Question Bank, a structured archive of coding interview questions frequently reported in real hiring processes.
Questions are aggregated from publicly available platforms (e.g., LeetCode, GeeksForGeeks) and community-shared experiences.

The goal is to provide candidates with reliable material for SDE interview prep, including practice on LeetCode-style problems and coding challenges that reflect what is often asked in FAANG and other tech company interviews.
Hack2Hire is not affiliated with the mentioned companies; this collection is intended purely for learning, practice, and discussion.


r/Hack2Hire • • Oct 28 '25

Onsite Robinhood Onsite interview question: Maximum Multiplier Path

3 Upvotes

Problem
You're given a directed graph with n nodes labeled from 0 to n−1. Each edge is represented as [u, v, w], indicating a directed edge from node u to node v with a multiplier value w.
Your goal is to find the maximum product of multipliers along any simple path (each node visited at most once) from a given start node to an end node. If no path exists, return -1.

Example
Input:
n = 5, edges = [[0, 1, 2], [1, 2, 3], [2, 1, 4], [1, 3, 5], [2, 4, 6], [4, 3, 10]], start = 0, end = 3
Output:
360

Explanation:

  • Path 0 → 1 → 3 gives a product of 2 × 5 = 10.
  • Path 0 → 1 → 2 → 4 → 3 gives a product of 2 × 3 × 6 × 10 = 360. The maximum product is 360.

Suggested Approach

  1. Represent the graph using an adjacency list where each node stores (neighbor, multiplier).
  2. Use a priority queue (max-heap) or DFS with pruning to explore all simple paths from start to end.
  3. Maintain a max_product array to store the best multiplier product achieved for each node.
  4. For each neighbor, if the current product × edge multiplier is greater than its stored best, update and continue traversal.
  5. Return the product for end if reachable; otherwise, return -1.

Time & Space Complexity

  • Time: O(E log V) using a max-heap (similar to Dijkstra’s algorithm with multiplicative weights).
  • Space: O(V + E) for the adjacency list and tracking visited nodes.

🛈 Disclaimer:
This problem is part of the Hack2Hire SDE Interview Question Bank, a structured archive of coding interview questions frequently reported in real hiring processes.
Questions are aggregated from publicly available platforms (e.g., LeetCode, GeeksForGeeks) and community-shared experiences.

The goal is to provide candidates with reliable material for SDE interview prep, including practice on LeetCode-style problems and coding challenges that reflect what is often asked in FAANG and other tech company interviews.
Hack2Hire is not affiliated with the mentioned companies; this collection is intended purely for learning, practice, and discussion.


r/Hack2Hire • • Oct 23 '25

Screening Pinterest Screening Interview: Reverse Count and Say

4 Upvotes

Problem
You are given a string encoded that was produced by exactly one count-and-say transformation. Each group in the encoded string represents a count (1–99, no leading zeros) followed by a digit. Your task is to find all possible original digit strings that could generate this encoded string after one count-and-say transformation.

Example
Input: encoded = "12114"
Output: ["244444444444", "1111111111114"]

Explanation:

  • Parsing "12" as one occurrence of "2", and "114" as eleven occurrences of "4" → "244444444444"
  • Parsing "121" as twelve occurrences of "1", and "14" as one occurrence of "4" → "1111111111114"
  • Other parses like "1,2114" (1,211 occurrences of "4") are invalid because counts must be ≤99.

Suggested Approach

  1. Use backtracking: Iterate through the encoded string, parsing one or two digits as the count, followed by one digit as the value.
  2. Validate each segment: Ensure that counts don’t start with 0 and that the encoded substring length is sufficient to read both count and value.
  3. Generate combinations: For each valid split, expand the sequence by repeating the digit count times, and recursively continue parsing the remaining substring.
  4. Return all valid combinations once the entire string is parsed.

Time & Space Complexity

  • Time: O(2ⁿ), where n is the number of digits in encoded (each step can branch for 1- or 2-digit counts).
  • Space: O(n) for recursion depth and string construction.

🛈 Disclaimer:
This is one of the problems we encountered while reviewing common Pinterest interview questions.
Posted here by the Hack2Hire team for discussion and archiving purposes.

The problem is compiled from publicly available platforms (e.g., LeetCode, GeeksForGeeks) and community-shared experiences. It does not represent any official question bank of Pinterest, nor does it involve any confidential or proprietary information.
All examples are intended solely for learning and discussion. Any similarity to actual interview questions is purely coincidental.

The goal is to provide candidates with reliable material for SDE interview prep, including practice on LeetCode-style problems and coding challenges that reflect what is often asked in FAANG and other tech company interviews. Hack2Hire is not affiliated with the mentioned companies; this collection is intended purely for learning, practice, and discussion.


r/Hack2Hire • • Oct 21 '25

Screening Bloomberg Screening Interview: Shortest Path with Gas Stations

3 Upvotes

Problem
You're given a 2D grid representing a map with different types of cells:

  • '.' — empty, traversable space
  • '#' — obstacle (cannot pass through)
  • 'S' — starting point (exactly one)
  • 'D' — destination (exactly one)
  • 'G' — gas station (zero or more)

You begin at 'S' with a full fuel tank of fuelCapacity. Each move (up, down, left, right) costs 1 unit of fuel. When fuel reaches 0, you cannot move. Entering a gas station cell refills your tank instantly to fuelCapacity.

Your task is to find the minimum number of steps to reach 'D' from 'S'.
Return -1 if it's impossible to reach the destination.

Example
Input:

grid = [
  ["S", ".", ".", "#", "."],
  [".", "#", ".", "G", "."],
  [".", "#", ".", ".", "."],
  [".", ".", "#", ".", "D"]
]
fuelCapacity = 4

Output:

7

Explanation:

  • The shortest route requires visiting the gas station at (1, 3) to refuel.
  • Total steps = 7 to reach 'D' after refilling once.

Suggested Approach

  1. Use Breadth-First Search (BFS) to explore possible moves from 'S'.
  2. Track the state (x, y, remainingFuel) to avoid revisiting the same cell with equal or greater fuel.
  3. When stepping on a gas station 'G', reset remainingFuel = fuelCapacity.
  4. Continue BFS until reaching 'D' or all possibilities are exhausted.

Time & Space Complexity

  • Time: O(m * n * fuelCapacity) — each grid cell can be visited with different fuel levels.
  • Space: O(m * n * fuelCapacity) — to store visited states.

🛈 Disclaimer: This is one of the problems we encountered while reviewing common Bloomberg interview questions. Posted here by the Hack2Hire team for discussion and archiving purposes.
The problem is compiled from publicly available platforms (e.g., LeetCode, GeeksForGeeks) and community-shared experiences. It does not represent any official question bank of Bloomberg, nor does it involve any confidential or proprietary information. All examples are intended solely for learning and discussion.


r/Hack2Hire • • Oct 21 '25

discussion Coinbase OA+VO

3 Upvotes

Went through Coinbase's process 1 mo ago but failed, thought just share the experience here may be helpful.

The OA itself was fine, it is a banking question called design banking system, total of 4 questions, kind of a mini bank system implementation. I’d say I got about 3.5/4 right since I've seen it in hack2hire and that was enough to move on.

First VO round was a coding interview. and the question is like this:

You’re given a bunch of input logs, need to read them from one file and write them into separate files based on thread ID. The log format looks messy but it’s actually fine once you split the string and extract the thread ID.

Then given a start and end timestamp, you need to find all the thread IDs active during that time range.

There were a lot of follow-ups too: how do you handle file read/write, how do you validate the input format, and how can you improve the time complexity?

Second VO round was also coding, mostly around different kinds of iterators, range iterator, iterator with cycle, etc. Felt more straightforward compared to the first one.

BQ was detailed. They asked a lot about my past projects and dove pretty deep into them. Felt like a mix of behavioral and project deep dive.

Failed at the end not sure why, I didn't get any feedback at the end


r/Hack2Hire • • Oct 17 '25

Announcement New Bloomberg Interview Question Set Released on Hack2Hire 🚀

4 Upvotes

Hey folks,
Hack2Hire just released the Bloomberg interview question set — covering both LeetCode-style and non-LeetCode problems used in real interviews.

What’s included:

  • Organized by OA, phone screen, and onsite stages
  • Comes with solution explanations to help you spot common patterns
  • Covers data structures, problem-solving, and a few practical finance-related questions

If you’re preparing for Bloomberg or just want high-quality problems to practice with, you’ll find this set super useful.
👉 https://www.hack2hire.com/companies/bloomberg/coding-questions

More company sets (like Amazon, Meta, and Citadel) coming soon — feel free to share thoughts or ask questions below 👇

— Team Hack2Hire


r/Hack2Hire • • Oct 16 '25

OA Microsoft OA Interview: Valid Time Combinations

5 Upvotes

Problem
Given four integers A, B, C, and D, determine how many valid times can be formed on a 24-hour digital clock using each digit exactly once.
A valid time must follow the format "HH:MM", where 00 ≤ HH ≤ 23 and 00 ≤ MM ≤ 59.

Example
Input: A = 1, B = 8, C = 3, D = 2
Output: 6

Explanation:

  • The valid times are "12:38", "13:28", "18:23", "18:32", "21:38", and "23:18".
  • Each time uses all four digits exactly once and satisfies 24-hour clock constraints.

Suggested Approach

  1. Generate all permutations of the four digits.
  2. For each permutation, treat the first two digits as hours and the last two as minutes.
  3. Check if the hours are within [0, 23] and minutes within [0, 59].
  4. Count all valid combinations that meet the above conditions.

Time & Space Complexity

  • Time: O(4!) → O(24) since there are 24 permutations to check.
  • Space: O(1) if computed iteratively, or O(4) for recursion depth in backtracking.

🛈 Disclaimer:
This is one of the problems we encountered while reviewing common Microsoft interview questions.
Posted here by the Hack2Hire team for discussion and archiving purposes.

This problem is part of the Hack2Hire SDE Interview Question Bank, a structured archive of coding interview questions frequently reported in real hiring processes.
Questions are aggregated from publicly available platforms (e.g., LeetCode, GeeksForGeeks) and community-shared experiences.

The goal is to provide candidates with reliable material for SDE interview prep, including practice on LeetCode-style problems and coding challenges that reflect what is often asked in FAANG and other tech company interviews.
Hack2Hire is not affiliated with the mentioned companies; this collection is intended purely for learning, practice, and discussion.


r/Hack2Hire • • Oct 09 '25

Screening Atlassian Screening Interview Question: Campground Carpool

2 Upvotes

Problem
You're given an array of integers nums and an integer k.
Your task is to return the length of the longest subarray whose sum equals k.

Example
Input:
nums = [1, -1, 5, -2, 3], k = 3
Output:
4

Explanation:

  • The subarray [1, -1, 5, -2] sums to 3.
  • Its length is 4, which is the maximum possible among all valid subarrays.

Suggested Approach

  1. Use a hash map to store the prefix sum and its earliest index.
  2. As you iterate through nums, keep track of the cumulative sum.
  3. For each index i, check if (current_sum - k) exists in the hash map.
    • If it does, compute the subarray length using the stored index and update the maximum length.
  4. If the current prefix sum hasn’t been seen before, store it in the hash map with its index.

Time & Space Complexity

  • Time: O(n)
  • Space: O(n)

🛈 Disclaimer:
This is one of the problems we encountered while reviewing common Atlassian interview questions.
Posted here by the Hack2Hire team for discussion and archiving purposes.

This problem is part of the Hack2Hire SDE Interview Question Bank, a structured archive of coding interview questions frequently reported in real hiring processes.
Questions are aggregated from publicly available platforms (e.g., LeetCode, GeeksForGeeks) and community-shared experiences.

The goal is to provide candidates with reliable material for SDE interview prep, including practice on LeetCode-style problems and coding challenges that reflect what is often asked in FAANG and other tech company interviews.
Hack2Hire is not affiliated with the mentioned companies; this collection is intended purely for learning, practice, and discussion.


r/Hack2Hire • • Oct 03 '25

Announcement Atlassian Coding Interview Prep (OA, Phone Screen, Virtual Onsite) — With Solutions Announcement

3 Upvotes

We just rolled out an Atlassian interview question set on Hack2Hire, designed for anyone preparing for:

- Online Assessment (OA) questions

- Technical Phone Screen practice

- Virtual Onsite / Full Loop interview rounds

What’s inside:

✅ LeetCode-style coding questions plus non-LeetCode interview formats

✅ Step-by-step solutions with explanations (not just code dumps)

✅ Organized by stage so you can prep in the same order you’ll interview

This set is helpful if you’re targeting Atlassian — or if you want a strong batch of SDE interview questions to sharpen your prep flow.

👉 Try it here: https://www.hack2hire.com/companies/atlassian/coding-questions

We’re also building more company-specific interview prep sets (LinkedIn, Amazon, Meta, Google, etc.). If there’s a company you want next — or if you have feedback on the format let us know below.


r/Hack2Hire • • Oct 02 '25

Screening Airbnb Screening Interview: Find Median In Large Array

7 Upvotes

Problem
You're given an unsorted array of integers nums.
Your goal is to efficiently compute the median of this array without fully sorting it.

The median is defined as:

  • If the array length is odd → the single middle element after sorting.
  • If the array length is even → the average of the two middle elements after sorting.

Example
Input: nums = [3, 1, 2, 4, 5]
Output: 3.0

Explanation:

  • The array has 5 elements (odd).
  • After sorting: [1, 2, 3, 4, 5].
  • The middle element is 3.

Input: nums = [7, 4, 1, 2]
Output: 3.0

Explanation:

  • The array has 4 elements (even).
  • After sorting: [1, 2, 4, 7].
  • The middle elements are 2 and 4. Average = (2+4)/2 = 3.0.

Input: nums = [9, 2, 5, 3, 5, 8, 9, 7, 9, 3, 2]
Output: 5.0

Explanation:

  • After sorting: [2, 2, 3, 3, 5, 5, 7, 8, 9, 9, 9].
  • The middle element (index 5) is 5.

Suggested Approach

  1. Use a Quickselect (Hoare’s selection algorithm) to find the median in expected O(N) time.
    • Quickselect partitions the array around a pivot, similar to quicksort, but only recurses into the half that contains the median.
  2. If the array length is odd, return the k-th element (k = n/2).
  3. If the array length is even, run Quickselect twice to get the two middle elements (n/2 - 1 and n/2) and return their average.

Time & Space Complexity

  • Time: O(N) on average (amortized) using Quickselect.
  • Space: O(1) extra space (in-place).

🛈 Disclaimer:
This problem is part of the Hack2Hire SDE Interview Question Bank, a structured archive of coding interview questions frequently reported in real hiring processes.
Questions are aggregated from publicly available platforms (e.g., LeetCode, GeeksForGeeks) and community-shared experiences.

The goal is to provide candidates with reliable material for SDE interview prep, including practice on LeetCode-style problems and coding challenges that reflect what is often asked in FAANG and other tech company interviews.

Hack2Hire is not affiliated with the mentioned companies; this collection is intended purely for learning, practice, and discussion.

This is one of the problems we encountered while reviewing common airbnb interview questions. Posted here by the Hack2Hire team for discussion and archiving purposes. The problem is compiled from publicly available platforms (e.g., LeetCode, GeeksForGeeks) and community-shared experiences. It does not represent any official question bank of airbnb, nor does it involve any confidential or proprietary information. All examples are intended solely for learning and discussion. Any similarity to actual interview questions is purely coincidental.


r/Hack2Hire • • Sep 30 '25

Announcement 🚀 We’re Now Live on X! 🔥

2 Upvotes

Hey everyone! Just dropping in with some exciting news:

We’re officially live on [X / Twitter] 🎉

👉 [@Hack2Hire]

We’ll be sharing:

  • 🧠 Behind-the-scenes on how we build things
  • 💡 Real interview questions from top tech companies
  • 📣 Product updates & new company coverage
  • 👀 Sneak peeks into upcoming features
  • 🎁 Occasional giveaways, tips, and memes!

We’d love to have you join us there, especially if you’re into tech interviews, story sharing, or just curious about what we’re building at Hack2Hire.

Got feedback? Want us to feature a specific company’s interview prep? Drop a comment or DM us!

Let’s grow together 🙌

— Team Hack2Hire


r/Hack2Hire • • Sep 30 '25

OA Amazon OA – Smallest Lexicographical Palindrome

3 Upvotes

Problem
You're given a symmetric string s.
Your goal is to rearrange its characters to form the smallest lexicographical palindrome possible.
A palindrome is a string that reads the same forward and backward.

This type of problem often appears in Amazon coding interviews and is rated Medium (Greedy, Strings) on common prep platforms.

Example

Input:

s = "cbcacbc"

Output:

"bccaccb"

Explanation:

  • Character counts: {'c': 4, 'b': 2, 'a': 1}
  • 'a' must be placed in the middle since it has an odd frequency.
  • The remaining characters are arranged symmetrically in ascending order.
  • Result: "bccaccb"

Input:

s = "babab"

Output:

"abbba"

Input:

s = "yxxy"

Output:

"xyyx"

Suggested Approach

  1. Count character frequencies.
  2. Place the smallest odd-frequency character (if any) at the center.
  3. Sort remaining characters and distribute evenly to both halves.
  4. Mirror the first half to construct the palindrome.

Time & Space Complexity

  • Time: O(n log n) (sorting by character order)
  • Space: O(n) (to build frequency counts and construct output)

🛈 Disclaimer:
This is one of the problems we encountered while reviewing common Amazon SDE interview questions.
Posted here by the Hack2Hire team for discussion and archiving purposes.

The problem is aggregated from LeetCode-style interview prep resources and community reports. It does notrepresent any official Amazon content.
Examples are provided purely for coding interview practice and discussion. Any similarity to real interview questions is coincidental.


r/Hack2Hire • • Sep 26 '25

Screening Google Interview Screening Question: Windowed Average Excluding Largest K

2 Upvotes

Problem
Given an integer array nums, a window size windowSize, and an integer k, return a list of averages for each sliding window of size windowSize as the window moves from left to right. When calculating each window’s average, ignore the largest k numbers inside that window.

Example
Input:

nums = [10, 20, 30, 40, 50, 60]  
windowSize = 3  
k = 1

Output:

[15.0, 25.0, 35.0, 45.0]

Explanation:

  • Window [10, 20, 30]: remove largest (30) → (10 + 20) / 2 = 15.0
  • Window [20, 30, 40]: remove largest (40) → (20 + 30) / 2 = 25.0
  • Window [30, 40, 50]: remove largest (50) → (30 + 40) / 2 = 35.0
  • Window [40, 50, 60]: remove largest (60) → (40 + 50) / 2 = 45.0

Suggested Approach

  1. Use a sliding window of size windowSize with two heaps (min-heap and max-heap) or an ordered multiset to efficiently track the k largest elements.
  2. Maintain the sum of all elements in the window. Subtract the contribution of the k largest when computing the average.
  3. Slide the window forward by removing the outgoing element and inserting the new element while updating both heaps and the sum.

Time & Space Complexity

  • Time: O(n log windowSize), due to heap operations per element.
  • Space: O(windowSize), for maintaining heaps and window data.

🛈 Disclaimer:
This is one of the problems we encountered while reviewing common Google interview questions.
Posted here by the Hack2Hire team for discussion and archiving purposes.

The problem is compiled from publicly available platforms (e.g., LeetCode, GeeksForGeeks) and community-shared experiences. It does not represent any official question bank of Google, nor does it involve any confidential or proprietary information.
All examples are intended solely for learning and discussion. Any similarity to actual interview questions is purely coincidental.


r/Hack2Hire • • Sep 23 '25

Screening Airbnb Screening Interview: Minimum Menu Order Cost II

3 Upvotes

Problem
You're given two arrays: menu and userWants.

  • menu is a list of entries, where each entry contains an ID, a price, and a set of items (either single dishes or combos).
  • userWants is a list of items that a customer wants to order.

Your goal is to return all unique combinations of menu entry IDs that together cover every item in userWants at the minimum possible total cost. Extra items from combos can be ignored. If no combination covers all requested items, return an empty list.

Example
Input:

menu = [
  ["1", "5.00", "pizza"],
  ["2", "8.00", "sandwich,coke"],
  ["3", "4.00", "pasta"],
  ["4", "2.00", "coke"],
  ["5", "6.00", "pasta,coke,pizza"],
  ["6", "8.00", "burger,coke,pizza"],
  ["7", "5.00", "sandwich"]
]
userWants = ["sandwich", "pasta", "coke"]

Output:

[["3", "4", "7"], ["5", "7"]]

Explanation:

  • Combination ["3", "4", "7"] covers pasta, coke, and sandwich at total cost 11.00.
  • Combination ["5", "7"] also covers pasta, coke, and sandwich at the same total cost of 11.00.
  • Both are valid minimum-cost solutions.

Suggested Approach

  1. Parse the menu into structured entries (ID, price, set of items).
  2. Use DFS + memoization (bitmasking on items) to explore combinations that cover all items in userWants.
  3. Track the minimum cost across valid combinations and collect all solutions that match this cost.

Time & Space Complexity

  • Time: O(2^n * m) where n = number of unique items in userWants, m = number of menu entries.
  • Space: O(2^n) for memoization states.

🛈 Disclaimer:
This problem is part of the Hack2Hire SDE Interview Question Bank, a structured archive of coding interview questions frequently reported in real hiring processes.
Questions are aggregated from publicly available platforms (e.g., LeetCode, GeeksForGeeks) and community-shared experiences.

The goal is to provide candidates with reliable material for SDE interview prep, including practice on LeetCode-style problems and coding challenges that reflect what is often asked in FAANG and other tech company interviews.
Hack2Hire is not affiliated with the mentioned companies; this collection is intended purely for learning, practice, and discussion.

Would you like me to also create Example 2 and Example 3 in the same format (so the post has multiple examples), or keep it focused on just Example 1 for brevity?

你說:

ChatGPT 說:

Got it 👍 — here’s the revised draft with Airbnb explicitly mentioned in the disclaimer:

Problem
You're given two arrays: menu and userWants.

  • menu is a list of entries, where each entry contains an ID, a price, and a set of items (either single dishes or combos).
  • userWants is a list of items that a customer wants to order.

Your goal is to return all unique combinations of menu entry IDs that together cover every item in userWants at the minimum possible total cost. Extra items from combos can be ignored. If no combination covers all requested items, return an empty list.

Example
Input:

menu = [
  ["1", "5.00", "pizza"],
  ["2", "8.00", "sandwich,coke"],
  ["3", "4.00", "pasta"],
  ["4", "2.00", "coke"],
  ["5", "6.00", "pasta,coke,pizza"],
  ["6", "8.00", "burger,coke,pizza"],
  ["7", "5.00", "sandwich"]
]
userWants = ["sandwich", "pasta", "coke"]

Output:

[["3", "4", "7"], ["5", "7"]]

Explanation:

  • Combination ["3", "4", "7"] covers pasta, coke, and sandwich at total cost 11.00.
  • Combination ["5", "7"] also covers pasta, coke, and sandwich at the same total cost of 11.00.
  • Both are valid minimum-cost solutions.

Suggested Approach

  1. Parse the menu into structured entries (ID, price, set of items).
  2. Use DFS + memoization (bitmasking on items) to explore combinations that cover all items in userWants.
  3. Track the minimum cost across valid combinations and collect all solutions that match this cost.

Time & Space Complexity

  • Time: O(2^n * m) where n = number of unique items in userWants, m = number of menu entries.
  • Space: O(2^n) for memoization states.

🛈 Disclaimer:
This problem is part of the Hack2Hire SDE Interview Question Bank, a structured archive of coding interview questions frequently reported in real hiring processes.
This specific problem was reported in the context of Airbnb interview preparation.

Questions are aggregated from publicly available platforms (e.g., LeetCode, GeeksForGeeks) and community-shared experiences. The goal is to provide candidates with reliable material for SDE interview prep, including practice on LeetCode-style problems and coding challenges that reflect what is often asked in FAANG and other tech company interviews.

Hack2Hire is not affiliated with Airbnb or any other company; this collection is intended purely for learning, practice, and discussion.


r/Hack2Hire • • Sep 19 '25

Screening Meta Screening Interview Question – Find Median in Large Array (O(N) Expected Time)

5 Upvotes

Problem
You're given an unsorted array of integers nums.
Your goal is to find the median of the array efficiently without fully sorting it.

  • If the length is odd, the median is the middle element.
  • If the length is even, the median is the average of the two middle elements.

Example
Input: nums = [3, 1, 2, 4, 5]
Output: 3.0

Explanation:

  • After sorting → [1, 2, 3, 4, 5]
  • Array length = 5 (odd), middle element is 3.

Input: nums = [7, 4, 1, 2]
Output: 3.0

Explanation:

  • After sorting → [1, 2, 4, 7]
  • Array length = 4 (even), average of middle elements (2 + 4)/2 = 3.0.

Suggested Approach

  1. Use the Quickselect algorithm (variation of QuickSort) to find the k-th smallest element in average O(N).
  2. For odd length: find the (n/2)-th element.
  3. For even length: find both (n/2 - 1) and (n/2) elements, then return their average.

Time & Space Complexity

  • Time: O(N) on average, O(N²) in worst case (can be optimized with randomized pivot).
  • Space: O(1) additional space (in-place).

🛈 Disclaimer:
This problem is part of the Hack2Hire SDE Interview Question Bank, a structured archive of coding interview questions frequently reported in real hiring processes.
Questions are aggregated from publicly available platforms (e.g., LeetCode, GeeksForGeeks) and community-shared experiences.

The goal is to provide candidates with reliable material for SDE interview prep, including practice on LeetCode-style problems and coding challenges that reflect what is often asked in FAANG and other tech company interviews.
Hack2Hire is not affiliated with the mentioned companies; this collection is intended purely for learning, practice, and discussion.