PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches

Quick Overview

This question evaluates skills in parsing and manipulating time-series user-event data, performing aggregations and path-frequency analysis, and understanding vectorized or parallel computations for performance.

  • Medium
  • Apple
  • Data Manipulation (SQL/Python)
  • Data Scientist

Analyze TSV File for User Page Visits and Patterns

Company: Apple

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: Medium

Interview Round: Technical Screen

visits +-----------+-----------+------+ | person_id | timestamp | page | +-----------+-----------+------+ | 1 | 100 | A | | 1 | 110 | B | | 1 | 150 | C | | 2 | 100 | B | | 2 | 120 | C | +-----------+-----------+------+ ##### Scenario You receive a TSV file in which each line contains a user’s chronological page-visit history formatted as timestamp,page and separated by “/t”. Business wants insights on usage and performance optimizations. ##### Question Parse the file and return the page with the highest total visit count. 2) For every visit, compute the residence time (current timestamp – next timestamp). Return the page with the greatest total residence time across all users. 3) Treat each user’s ordered page sequence as a path. Return the most frequent complete path (e.g., "A→B→C"). 4) #2 can be slow with explicit loops. Rewrite the residence-time computation so it can execute in parallel / vectorized form (e.g., time[i] – time[i-1]) and explain the performance benefit. ##### Hints Load into pandas, sort by person_id & timestamp, use groupby + diff/shift, Counter or groupby agg, and vectorized numpy operations for parallelism.

Quick Answer: This question evaluates skills in parsing and manipulating time-series user-event data, performing aggregations and path-frequency analysis, and understanding vectorized or parallel computations for performance.

Last updated: Mar 29, 2026

Loading coding console...

PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Detect sessions and gaps using SQL LEAD - Apple (Medium)
  • Write queries to compute salary and budget stats - Apple (easy)
  • Compute and Rank Store Revenue by Region Using Pandas - Apple (Medium)
  • Explain Python lists, dicts, and concurrency - Apple (Medium)