← eBay Interview Insights

eBay·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

eBay software engineering interview with a product recommendation problem that looked approachable on the surface but had some real complexity hiding in the follow-ups. The Java refactoring question at the end caught me a bit flat-footed.

Questions Asked (2)

Q1

You're given a list of browser sessions, each containing a target product ID and other product IDs. For every other product that appears in the same session as the target, count how many sessions they co-occur in. Return the top k products by co-occurrence count, sorted descending with tie-breaking by product ID.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

I got the frequency map part pretty quickly but fumbled the bucket sort explanation for a bit.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use a hash map to count co-occurrences: for each session, iterate over the other product IDs and increment a counter for each (target, other) pair. Then sort the resulting products by count descending and product ID ascending, and return the top k. Discuss trade-offs between time and space, and how to handle large-scale data.

Pro tip: Clarify assumptions upfront: whether the target product can appear multiple times in a session, whether sessions can be empty, and if k exceeds the number of unique co-occurring products. Also, mention that in a real eBay-scale system, you'd likely use a distributed approach like MapReduce to handle the data volume.

1. Clarify requirements and edge cases

Ask about input size, whether the target product is guaranteed to be in each session, and how to handle ties. Confirm output format and if k can be larger than the number of unique products.

2. Design the counting algorithm

Use a hash map to count co-occurrences: for each session, iterate over other product IDs and increment their count. Ensure the target product itself is excluded from the counts.

3. Sort and select top k

Convert the hash map entries to a list and sort by count descending, then by product ID ascending. Return the first k elements. Discuss using a heap for better efficiency if k is small relative to the number of unique products.

4. Analyze complexity and trade-offs

State time complexity: O(N + M log M) where N is total number of product occurrences across sessions and M is number of unique co-occurring products. Space complexity: O(M). Mention that a heap can reduce sorting to O(M log k).

5. Discuss scalability and optimizations

For large-scale data, propose distributed counting (e.g., MapReduce) or streaming approaches. Mention memory considerations and potential use of approximate algorithms if exact counts are not required.

Key Points to Mention

  • Hash map for efficient counting of co-occurrences
  • Sorting with custom comparator for tie-breaking by product ID
  • Time and space complexity analysis
  • Using a min-heap to find top k efficiently when k is small
  • Handling edge cases: empty sessions, target not present, k larger than unique products
  • Scalability: distributed processing or streaming for large datasets

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

How would you refactor this solution for production-quality Java, using Streams, immutable maps, and a clean separation of concerns?

Technical Trade-offsAPI & Integrations
Author's notes

Blanked for a second here.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the current solution's pain points and production requirements, then propose a refactoring plan that applies Java Streams for declarative data processing, immutable maps for thread-safe configuration or caching, and layered separation of concerns (e.g., controller/service/repository). Emphasize trade-offs like readability vs. performance and testability, and tie your choices to eBay's scale and reliability needs.

Pro tip: Mention that you'd introduce the refactoring incrementally behind tests, using feature flags if needed, to avoid breaking existing behavior—this shows you understand production risk management, not just code aesthetics.

1. Clarify requirements and constraints

Ask about expected data volume, latency, concurrency, and existing dependencies to ground your refactoring decisions in real production needs.

2. Identify code smells and separation gaps

Point out issues like mutable shared state, mixed I/O and business logic, or imperative loops that obscure intent, and map them to clean architecture layers.

3. Apply Streams and immutable maps

Show how Streams can replace imperative loops for filtering/transforming collections, and how immutable maps (e.g., Map.of, Collectors.toUnmodifiableMap) eliminate side effects and enable safe sharing.

4. Refactor for separation of concerns

Propose extracting distinct responsibilities into classes or interfaces (e.g., a service for business logic, a repository for data access, a mapper for DTO conversion) and using dependency injection.

5. Validate with tests and discuss trade-offs

Describe how you'd write unit tests for each layer, benchmark performance if needed, and weigh readability, memory overhead, and team familiarity against the benefits.

Key Points to Mention

  • Use of Java Streams for declarative, side-effect-free data processing (e.g., filter, map, collect) and when to avoid them (e.g., complex stateful logic).
  • Immutable maps via Map.of, Map.copyOf, or Collectors.toUnmodifiableMap to ensure thread safety and prevent accidental modification.
  • Separation of concerns: distinct layers for API/controller, service/business logic, and data access, with clear interfaces and dependency inversion.
  • Trade-offs: Streams can be less readable for complex logic; immutable collections may increase memory; refactoring risks regression without tests.
  • Testing strategy: unit tests for each layer, integration tests for data flow, and possibly contract tests for APIs.
  • Production readiness: logging, monitoring, error handling, and incremental rollout (e.g., feature flags) to mitigate risk.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.