Google (Alphabet) interview questions & answers

20 real Google (Alphabet) interview questions with full model answers — System design, Coding, Behavioral, Technical. Drawn from the same verified bank ChannelPulse drills from (261 Google (Alphabet) questions in total).

BehavioralEasyGoogle (Alphabet)Software EngineerOnsite

1. Describe a time when you faced a serious conflict at work (e.g., disagreement on technical direction, priorities, scope, or execution) involving on…

The full question

Describe a time when you faced a serious conflict at work (e.g., disagreement on technical direction, priorities, scope, or execution) involving one or more of:

  • A peer engineer
  • Your manager / leadership
  • Cross-functional stakeholders (PM, DS, SRE, Security, etc.)

What to cover

  1. Situation & context: What was the project, timeline pressure, and what was at stake?
  2. Conflict details: What exactly did each party want, and why?
  3. Your actions: How did you de-escalate, align incentives, and drive a decision?
  4. Outcome: What changed as a result (delivery, quality, relationship, business impact)?
  5. Reflection: If you faced the same situation again, what would you do better or differently?

Evaluation focus

  • Ability to mediate conflict constructively
  • Expectation management upward and outward
  • Clarity of communication and decision-making under ambiguity

Model answer

Situation

In my role as a software engineer at a tech company, I was part of a team tasked with developing a new feature for our flagship product. The project had a tight deadline due to an upcoming major product launch, and there was significant pressure to deliver high-quality work on time. The stakes were high as this feature was a key selling point for the product and critical for our competitive positioning.

Task

During the project, I encountered a serious conflict with a peer engineer and a product manager regarding the technical direction of the feature. The peer engineer advocated for a more complex solution that promised greater scalability, while the product manager prioritized a simpler approach to meet the deadline and ensure immediate functionality.

Action

  • I initiated a meeting with both parties to discuss the conflict openly. My goal was to understand their perspectives fully and find a common ground.
  • I listened actively to the peer engineer's concerns about scalability and the product manager's focus on the timeline. I acknowledged the validity of both viewpoints, which helped in de-escalating tensions.
  • To align incentives, I proposed a phased approach: we would implement the simpler solution first to meet the immediate deadline, followed by an iterative enhancement to address scalability post-launch. This compromise allowed us to meet the product manager's timeline while not dismissing the engineer's concerns.
  • I facilitated a follow-up meeting to outline the phased plan, ensuring everyone was clear on the new direction and their responsibilities. I also documented the plan and shared it with the team to maintain transparency and accountability.

Result

The phased approach was successful. We delivered the feature on time for the product launch, which was well-received by stakeholders and customers. Post-launch, we were able to enhance the feature's scalability without major disruptions. The conflict resolution not only preserved team harmony but also improved our collaborative dynamics. Reflecting on the experience, I learned the importance of balancing immediate business needs with long-term technical goals and the value of clear, empathetic communication in resolving conflicts.

Reflection

If faced with a similar situation again, I would involve a neutral third party earlier in the process to facilitate the discussion. This could provide additional perspectives and help in reaching a resolution more efficiently. Additionally, I would ensure more frequent check-ins with all stakeholders to preemptively address any emerging conflicts.

BehavioralEasyGoogle (Alphabet)

2. Tell me about a time you had to learn a new technology quickly to complete a project.

Model answer

Situation

In my previous role as a software developer at a mid-sized tech company, I was assigned to a project that required integrating a new cloud-based service into our existing infrastructure. This was crucial because the service promised to significantly enhance our application's performance and scalability. However, I had no prior experience with this specific technology, and the timeline was tight due to an upcoming product launch.

Task

My primary responsibility was to quickly learn and implement this new technology to ensure the integration was seamless and met the performance benchmarks. The key constraint was the limited time available to both learn and apply this technology effectively.

Action

  • I began by dedicating the first few days to intensive research and learning. I utilized official documentation, online courses, and community forums to get up to speed with the technology.
  • To accelerate my learning, I reached out to a colleague who had experience with similar technologies. We scheduled a few knowledge-sharing sessions where I could ask specific questions and gain insights from their practical experience.
  • I set up a small prototype environment to experiment with the technology. This hands-on approach allowed me to test various configurations and understand the nuances of the service.
  • I broke down the integration task into smaller, manageable components and set mini-deadlines to track my progress. This helped me stay focused and ensured that I was making consistent progress.
  • Throughout the process, I maintained open communication with my team and project manager, providing regular updates on my progress and any challenges I encountered. This transparency helped manage expectations and allowed the team to plan accordingly.

Result

As a result of these efforts, I successfully integrated the new cloud-based service into our application ahead of the deadline. The integration led to a 25% improvement in application performance, which was well-received by both the team and our clients. This experience taught me the value of leveraging available resources and the importance of effective time management when learning new technologies under pressure. It reinforced my ability to adapt quickly and deliver results in challenging situations.

BehavioralEasyGoogle (Alphabet)DevOps / SRE

3. Can you tell me about a time you automated a manual process?

The full question

Can you tell me about a time you automated a manual process? What was the outcome?

Model answer

Situation In my previous role as a software engineer at a mid-sized e-commerce company, I noticed that our team was spending a significant amount of time manually generating and distributing weekly sales reports. This process involved extracting data from multiple sources, compiling it into a spreadsheet, and then emailing it to various stakeholders. The manual nature of this task not only consumed valuable time but also introduced opportunities for human error, which could affect decision-making.

Task My goal was to automate the report generation and distribution process to save time and reduce errors. The key constraint was ensuring that the automated solution could integrate seamlessly with our existing systems and deliver reports in a format that stakeholders were already accustomed to.

Action

  • I began by mapping out the entire manual process to understand each step and identify potential automation points.
  • I chose to use a combination of Python scripts and a scheduling tool like cron jobs to automate data extraction from our databases and third-party APIs.
  • I developed a script that compiled the extracted data into a formatted spreadsheet that matched the existing manual reports.
  • To automate distribution, I integrated the script with our email server, ensuring that the reports were sent out to the relevant stakeholders every Monday morning without fail.
  • I conducted a series of tests to ensure data accuracy and reliability of the automated process, involving key stakeholders to validate the report format and content.
  • Finally, I documented the entire process and trained a colleague to maintain the system, ensuring continuity in case of my absence.

Result The automation reduced the time spent on report generation from approximately 10 hours per week to virtually zero, freeing up the team to focus on more strategic tasks. Stakeholders received their reports consistently and without errors, leading to improved trust in the data. This project not only enhanced operational efficiency but also demonstrated the value of automation in our workflows. I learned the importance of thoroughly understanding existing processes before implementing automation, ensuring that solutions are both effective and sustainable.

BehavioralEasyGoogle (Alphabet)Software Engineer

4. How do you prioritize your tasks when working on multiple projects?

Model answer

Situation

In my role as a software engineer at a mid-sized tech company, I was often tasked with managing multiple projects simultaneously. At one point, I was responsible for leading the development of a new feature for our flagship product while also supporting a critical bug fix for another project. Both tasks were high priority, and the challenge was to ensure timely delivery without compromising quality.

Task

My primary goal was to effectively prioritize my workload to meet the deadlines for both projects. The key constraint was balancing the immediate need for the bug fix with the strategic importance of the new feature development.

Action

  • I started by listing all tasks for both projects and categorizing them based on urgency and impact. This helped me identify which tasks were critical and which could be deferred.
  • I used a prioritization matrix to assess each task's urgency and importance. This visual tool allowed me to focus on tasks that were both urgent and important, ensuring that I addressed the most critical issues first.
  • I communicated proactively with stakeholders from both projects to understand their expectations and any potential changes in priorities. This open line of communication helped me adjust my plans as needed and manage expectations effectively.
  • I allocated specific time blocks in my calendar for focused work on each project, ensuring that I dedicated uninterrupted time to high-priority tasks. This approach minimized context switching and increased my productivity.
  • I regularly reviewed my progress and adjusted priorities as necessary. For instance, when the bug fix required immediate attention due to a new customer complaint, I temporarily shifted focus to resolve it quickly.

Result

By effectively prioritizing my tasks, I was able to deliver the bug fix within the expected timeframe, which improved customer satisfaction and reduced support tickets by 20%. Simultaneously, I made significant progress on the new feature, which was completed on schedule and contributed to a 15% increase in user engagement. This experience reinforced the importance of structured prioritization and proactive communication in managing multiple projects successfully.

CodingEasyGoogle (Alphabet)Software EngineerOnsite

5. You are given an n x n grid initially filled with zeroes and a list of inclusive rectangular updates.

The full question

You are given an n x n grid initially filled with zeroes and a list of inclusive rectangular updates. Each rectangle adds one to every covered cell.

Implement:

range_add_counts(n, rectangles) -> list[list[int]]

Each rectangle is [row1, col1, row2, col2], using zero-based inclusive coordinates. Return the final grid, where each cell contains the number of rectangles covering it.

Example

n = 3
rectangles = [\
[0, 0, 1, 1],\
[1, 1, 2, 2]\
]

result = [\
[1, 1, 0],\
[1, 2, 1],\
[0, 1, 1]\
]

Cell (1, 1) is covered by both rectangles.

Constraints

  • 1 <= n <= 500
  • 0 <= len(rectangles) <= 100000
  • 0 <= row1 <= row2 < n
  • 0 <= col1 <= col2 < n
  • Duplicate rectangles count as separate updates.
  • If rectangles is empty, return an all-zero grid.

Clarifications

  • Both lower and upper rectangle coordinates are included.
  • The input list must not be mutated.
  • Returning a newly allocated matrix is expected.

Model answer

def range_add_counts(n, rectangles):
    # Initialize a grid with all zeroes
    grid = [[0] * (n + 1) for _ in range(n + 1)]

    # Apply the difference array technique
    for row1, col1, row2, col2 in rectangles:
        grid[row1][col1] += 1
        if col2 + 1 < n:
            grid[row1][col2 + 1] -= 1
        if row2 + 1 < n:
            grid[row2 + 1][col1] -= 1
        if row2 + 1 < n and col2 + 1 < n:
            grid[row2 + 1][col2 + 1] += 1

    # Calculate prefix sums to get the final grid
    for r in range(n):
        for c in range(n):
            if r > 0:
                grid[r][c] += grid[r - 1][c]
            if c > 0:
                grid[r][c] += grid[r][c - 1]
            if r > 0 and c > 0:
                grid[r][c] -= grid[r - 1][c - 1]

    # Trim the grid to n x n size
    return [row[:n] for row in grid[:n]]

# Example usage:
n = 3
rectangles = [
    [0, 0, 1, 1],
    [1, 1, 2, 2]
]
result = range_add_counts(n, rectangles)
print(result)  # Output: [[1, 1, 0], [1, 2, 1], [0, 1, 1]]
  • Approach:
  • Use a difference array technique to efficiently apply rectangle updates.
  • For each rectangle, increment the top-left corner and decrement the positions just outside the rectangle to mark boundaries.
  • Compute prefix sums to propagate the updates across the grid.
  • Trim the grid to the required n x n size.
  • Complexity:
  • Time: O(n^2 + m), where n is the grid size and m is the number of rectangles. The prefix sum computation is O(n^2), and applying the rectangle updates is O(m).
  • Space: O(n^2) for the grid.
CodingEasyGoogle (Alphabet)

6. Given a list of integers, write a function to find the maximum product of any two distinct numbers in the list.

Model answer

function maxProduct(nums) {
    if (nums.length < 2) {
        throw new Error("At least two numbers are required");
    }

    // Initialize the two largest and two smallest numbers
    let max1 = -Infinity, max2 = -Infinity;
    let min1 = Infinity, min2 = Infinity;

    for (let num of nums) {
        // Update the two largest numbers
        if (num > max1) {
            max2 = max1;
            max1 = num;
        } else if (num > max2) {
            max2 = num;
        }

        // Update the two smallest numbers
        if (num < min1) {
            min2 = min1;
            min1 = num;
        } else if (num < min2) {
            min2 = num;
        }
    }

    // Maximum product can be from two largest numbers or two smallest numbers (if negative)
    return Math.max(max1 * max2, min1 * min2);
}

// Example usage:
console.log(maxProduct([1, 10, -5, 1, -100])); // Output: 1000
  • Approach:
  • Traverse the list to find the two largest and two smallest numbers.
  • The two largest numbers give a potential maximum product.
  • The two smallest numbers (if negative) might also provide a large positive product.
  • Return the maximum of these two products.
  • Complexity:
  • Time: O(n), where n is the number of elements in the list, since we traverse the list once.
  • Space: O(1), as we use a constant amount of extra space.
CodingEasyGoogle (Alphabet)

7. Given an array of integers, return indices of the two numbers such that they add up to a specific target.

Model answer

function twoSum(nums, target) {
    // Create a map to store the difference and its index
    const numMap = new Map();

    // Iterate through the array
    for (let i = 0; i < nums.length; i++) {
        // Calculate the difference needed to reach the target
        const complement = target - nums[i];

        // Check if the complement exists in the map
        if (numMap.has(complement)) {
            // If found, return the indices of the two numbers
            return [numMap.get(complement), i];
        }

        // Otherwise, add the current number and its index to the map
        numMap.set(nums[i], i);
    }

    // If no solution is found, return an empty array
    return [];
}

// Example usage:
// const result = twoSum([2, 7, 11, 15], 9);
// console.log(result); // Output: [0, 1]
  • Approach:
  • Use a hash map to store each number's complement (target - current number) and its index as you iterate through the array.
  • For each number, check if its complement is already in the map.
  • If it is, return the current index and the index of the complement.
  • If not, add the number and its index to the map and continue.
  • Complexity:
  • Time: O(n), where n is the number of elements in the array. Each lookup and insertion in the hash map is O(1) on average.
  • Space: O(n), for storing elements in the hash map.
CodingEasyGoogle (Alphabet)

8. Reverse a string.

Model answer

function reverseString(s) {
  // Convert the string to an array of characters
  let charArray = s.split('');
  
  // Initialize two pointers
  let left = 0;
  let right = charArray.length - 1;
  
  // Swap characters until the pointers meet in the middle
  while (left < right) {
    // Swap the characters at left and right indices
    let temp = charArray[left];
    charArray[left] = charArray[right];
    charArray[right] = temp;
    
    // Move the pointers towards the center
    left++;
    right--;
  }
  
  // Convert the array of characters back to a string
  return charArray.join('');
}

// Example usage:
console.log(reverseString("hello")); // Output: "olleh"
  • Approach:
  • Convert the string to an array to facilitate in-place modifications.
  • Use two pointers, one starting at the beginning (left) and one at the end (right) of the array.
  • Swap the characters at these pointers and move the pointers towards the center.
  • Continue swapping until the pointers meet or cross each other.
  • Convert the modified array back to a string and return it.
  • Complexity:
  • Time: O(n), where n is the length of the string, as each character is visited once.
  • Space: O(n), due to the array used for reversing the string.
Product & growthEasyGoogle (Alphabet)Product Manager

9. What is your favorite Google product and why?

Model answer

Favorite product: Google Search.

Why: Google Search is intuitive, fast, and constantly evolving to meet user needs. It's the backbone of information retrieval and has revolutionized the way people access knowledge.

Features:

  • Relevance: Advanced algorithms ensure relevant results.
  • Speed: Quick response times enhance user experience.
  • Integration: Seamless integration with other Google services.

Impact: Google Search democratizes access to information, supports businesses through SEO, and continually innovates with AI-driven features like voice search and personalized results.

Recommendation: Continue evolving AI capabilities to maintain leadership in search technology.

Product & growthMediumGoogle (Alphabet)Data ScientistAnalytics / experimentation round

10. How would you detect if treatment effect differs by segment?

Model answer

The flow

  1. Define Hypothesis & Metrics: Identify the segments and metrics to measure the treatment effect.
  2. Unit of Randomization: Determine the unit (e.g., user, session) for random assignment.
  3. Power & Sample Size: Calculate the required sample size for each segment to detect a meaningful effect.
  4. Run Experiment & Guard Against Peeking: Execute the experiment ensuring no premature analysis.
  5. Analyze Results with Guardrails: Use statistical tests to compare treatment effects across segments.
  6. Interpret & Report Findings: Conclude if the treatment effect varies by segment.

The answer

1. Define Hypothesis & Metrics

  • Hypothesis: The treatment effect varies across different user segments (e.g., age, location).
  • Metrics: Conversion rate, average revenue per user.

2. Unit of Randomization

  • Choose user-level randomization to ensure each user is consistently exposed to the same treatment.

3. Power & Sample Size

  • Calculate sample size for each segment using a power analysis tool.
  • Assume a baseline conversion rate of 5% and a desired minimum detectable effect of 1%.
  • Use a significance level of 0.05 and power of 0.8.

4. Run Experiment & Guard Against Peeking

  • Implement the experiment with a fixed duration, avoiding interim analysis.
  • Ensure data collection is consistent and unbiased.

5. Analyze Results with Guardrails

  • Use ANOVA or similar statistical tests to compare treatment effects across segments.
  • Adjust for multiple comparisons using Bonferroni correction.

6. Interpret & Report Findings

  • If p-values for segment interactions are significant, conclude that treatment effects differ by segment.
  • Recommendation: Tailor strategies for segments where treatment is more effective.
import numpy as np
from statsmodels.stats.power import TTestIndPower

# Parameters
baseline_rate = 0.05
min_effect = 0.01
alpha = 0.05
power = 0.8

# Calculate sample size
analysis = TTestIndPower()
sample_size = analysis.solve_power(effect_size=min_effect/baseline_rate, 
                                   alpha=alpha, power=power, 
                                   alternative='two-sided')
print(f'Required sample size per segment: {np.ceil(sample_size)}')

Why this works

  • Interviewer Focus: Tests the candidate's understanding of segmentation analysis and statistical rigor.
  • Sanity Check: Ensures the candidate considers sample size and statistical power, crucial for detecting effects.
  • Common Pitfall: Weak answers often ignore the need for segment-specific sample size calculations or fail to account for multiple comparisons.
Product & growthMediumGoogle (Alphabet)Product Manager

11. How would you improve Google Maps for visually impaired users?

Model answer

Clarify & scope: The goal is to enhance Google Maps for visually impaired users, focusing on navigation and accessibility. Assume the app is currently underutilized by this segment due to usability challenges.

User segments & pain points: Focus on visually impaired users who rely on assistive technology. Pain points include difficulty in understanding visual maps, lack of audio cues, and challenges in identifying landmarks.

Goals & success metrics: The North Star metric is increased usage by visually impaired users. Guardrails include user satisfaction scores and reduced navigation errors.

Solutions:

  1. Enhanced Audio Navigation: Provide detailed, turn-by-turn audio instructions.
  2. Vibration Alerts: Use haptic feedback for upcoming turns or changes in direction.
  3. Landmark Identification: Integrate with image recognition to describe surroundings.

Recommendation: Prioritize Enhanced Audio Navigation as it directly addresses core navigation needs.

userflow
  userStart --> AudioNavigation --> VibrationAlerts --> LandmarkID
Diagram

Prioritization & trade-offs: Use RICE framework. Enhanced Audio Navigation scores high on reach and impact but requires moderate effort.

MVP, measurement & rollout: Start with a pilot in a city with a significant visually impaired population. Measure success through user feedback and error rate reduction.

Product & growthMediumGoogle (Alphabet)Product Manager

12. How would you design a feature for Google Photos to help users organize their photo collections?

Model answer

Clarify & scope: The goal is to help users organize their photo collections in Google Photos. Assume users have large, unorganized libraries.

User segments & pain points: Focus on casual photographers with extensive photo libraries. Pain points include difficulty in sorting and categorizing photos.

Goals & success metrics: The North Star metric is increased user engagement with organizational features. Guardrails include user satisfaction and feature adoption rates.

Solutions:

  1. AI-Powered Categorization: Automatically sorts photos into albums based on content and metadata.
  2. Customizable Tags: Allows users to tag photos for personalized organization.
  3. Shared Album Suggestions: Recommends albums to share with friends and family based on recent events.

Recommendation: Prioritize AI-Powered Categorization for its potential to automate organization.

userflow
  userStart --> AICategorization --> CustomTags --> SharedAlbumSuggestions
Diagram

Prioritization & trade-offs: Use RICE framework. AI-Powered Categorization has high impact and user value but requires significant AI development.

MVP, measurement & rollout: Launch a beta version with AI categorization, measure user engagement, and iterate based on user feedback.

System designEasyGoogle (Alphabet)DevOps / SRE

13. Sketch a design for a simple notification system.

Model answer

1. Requirements & scale

Functional Requirements:

  • The system should send notifications to users.
  • Support multiple notification channels (e.g., email, SMS, push notifications).
  • Allow scheduling of notifications.
  • Provide a retry mechanism for failed notifications.

Non-Functional Requirements:

  • High availability and reliability.
  • Scalability to handle a large number of notifications.
  • Low latency in delivering notifications.

Estimates:

  • Assume 1 million users with an average of 5 notifications per user per day.
  • Peak load: 5 million notifications/day, approximately 58 notifications/second.
  • Storage: Minimal, primarily for logs and retry queues.
  • Bandwidth: Depends on notification size and frequency.

2. High-level architecture

flowchart TD
    subgraph Client
        A["User Device"]
    end

    subgraph Edge/CDN
        B["CDN"]
    end

    subgraph Load Balancer
        C["Load Balancer"]
    end

    subgraph API / Services
        D["Notification API"]
        E["Scheduler Service"]
    end

    subgraph Cache
        F["In-memory Cache (Redis)"]
    end

    subgraph Datastores
        G["Metadata DB (SQL)"]
        H["Logs DB (NoSQL)"]
    end

    subgraph Message Queue
        I["Message Queue (Pub/Sub)"]
    end

    subgraph Workers
        J["Notification Workers"]
    end

    A --> B --> C --> D
    D --> G
    D --> I
    E --> I
    I --> J
    J --> F
    J --> H
    J --> A
Diagram

3. API design

  • POST /notifications: Create a new notification request.
  • GET /notifications/{id}: Retrieve the status of a notification.
  • POST /notifications/schedule: Schedule a notification for future delivery.
  • GET /notifications/logs: Retrieve logs of sent notifications.

4. Data model & storage

Datastores:

  • Metadata DB (SQL): Stores user preferences, notification templates, and scheduling information. Chosen for its ACID properties and structured data requirements.
  • Logs DB (NoSQL): Stores logs of sent notifications. Chosen for its scalability and ability to handle large volumes of unstructured data.

Key Tables:

  • UserPreferences: user_id, preferred_channel, email, phone_number.
  • NotificationTemplate: template_id, content, channel.
  • ScheduledNotifications: notification_id, user_id, template_id, scheduled_time.

Partition Key:

  • For ScheduledNotifications, use user_id to distribute load evenly.

5. Deep dive

The core of the notification system is the reliable delivery of messages through various channels. This involves using a message queue to decouple the sending process and ensure reliability.

sequenceDiagram
    participant Client
    participant API
    participant Queue
    participant Worker
    participant Channel

    Client->>API: POST /notifications
    API->>Queue: Enqueue notification
    loop Process notifications
        Queue->>Worker: Dequeue notification
        Worker->>Channel: Send notification (e.g., email/SMS)
        Channel-->>Worker: Acknowledge receipt
        Worker->>API: Update notification status
    end
Diagram

6. Scale, bottlenecks & trade-offs

Scalability:

  • Use a message queue (e.g., Pub/Sub) to handle high throughput and decouple the processing of notifications from their creation.
  • Horizontal scaling of workers to handle increased load.

Bottlenecks:

  • The message queue can become a bottleneck if not properly scaled or if message processing is slow.
  • Network latency can affect real-time notification delivery.

Trade-offs:

  • Consistency vs. Availability: Opt for eventual consistency in notification delivery to ensure high availability.
  • Push vs. Pull: Use a push model for immediate notifications and a pull model for scheduled notifications.
  • SQL vs. NoSQL: Use SQL for structured data with strong consistency needs and NoSQL for unstructured log data requiring high write throughput.

Failure Modes:

  • Implement retries with exponential backoff for failed notifications.
  • Use logging and monitoring to detect and resolve issues promptly.
System designEasyGoogle (Alphabet)

14. Design a URL shortening service like goo.gl.

The full question

Design a URL shortening service like goo.gl. What are the key components?

Model answer

1. Requirements & scale

Functional Requirements:

  • Shorten a given URL.
  • Redirect users from a short URL to the original URL.
  • Track the number of times a short URL is accessed.
  • Provide an API for URL shortening and redirection.

Non-Functional Requirements:

  • High availability and low latency.
  • Scalability to handle millions of URL shortening requests and redirections.
  • Reliability and fault tolerance to ensure data is not lost.

Estimates:

  • Assume 100 million new URLs per month, which is about 38 URLs per second.
  • Assume 1 billion redirections per month, which is about 385 redirections per second.
  • URL storage: If each URL entry is approximately 500 bytes, storing 100 million URLs would require around 50 GB per month.

2. High-level architecture

flowchart TD
    subgraph Client
        A[User]
    end
    subgraph Edge/CDN
        B[CDN]
    end
    subgraph Load Balancer
        C[Load Balancer]
    end
    subgraph API / Services
        D[URL Shortening Service]
        E[Redirection Service]
    end
    subgraph Cache
        F[Cache (Redis)]
    end
    subgraph Datastores
        G["SQL DB"]
        H["NoSQL DB"]
    end
    subgraph Message Queue
        I[Queue]
    end
    subgraph Workers
        J[Analytics Worker]
    end

    A -->|Shorten URL Request| B
    B --> C
    C -->|API Request| D
    D -->|Store URL| G
    D -->|Generate Short URL| H
    A -->|Redirection Request| B
    B --> C
    C -->|Fetch Original URL| E
    E -->|Check Cache| F
    F -->|Cache Miss| H
    E -->|Redirect| A
    E -->|Log Access| I
    I --> J
    J -->|Update Analytics| G
Diagram

3. API design

  • POST /shorten: Accepts a long URL and returns a shortened URL.
  • GET /{shortUrl}: Redirects to the original URL associated with the short URL.
  • GET /analytics/{shortUrl}: Returns access statistics for a given short URL.

4. Data model & storage

Datastores:

  • SQL Database: Used for storing user data and analytics due to its ACID properties.
  • NoSQL Database: Used for storing URL mappings for scalability and quick access.

Key Tables:

  • URL_Mappings:
  • short_url (Primary Key)
  • original_url
  • created_at
  • URL_Analytics:
  • short_url (Foreign Key)
  • access_count
  • last_accessed

Partitioning:

  • Use the short_url as the partition key in the NoSQL database to evenly distribute load.

5. Deep dive

The core functionality of a URL shortening service is generating a unique short URL for a given long URL. This can be efficiently achieved using a base conversion algorithm. Here's a sequence diagram illustrating the URL shortening process:

sequenceDiagram
    participant User
    participant ShorteningService
    participant SQLDB
    participant NoSQLDB

    User->>ShorteningService: POST /shorten
    ShorteningService->>NoSQLDB: Check if URL exists
    NoSQLDB-->>ShorteningService: URL not found
    ShorteningService->>ShorteningService: Generate short URL
    ShorteningService->>NoSQLDB: Store short URL mapping
    ShorteningService->>SQLDB: Log URL creation
    ShorteningService-->>User: Return short URL
Diagram

The service generates a unique identifier for each URL using a base-62 encoding of a sequential ID or a hash function. This identifier is then stored in the NoSQL database along with the original URL.

6. Scale, bottlenecks & trade-offs

Scaling:

  • Use horizontal scaling for both the NoSQL and SQL databases to handle increased load.
  • Implement read replicas for the SQL database to distribute read traffic.

Caching:

  • Use Redis to cache frequently accessed URL mappings, reducing database load and improving latency.

Bottlenecks:

  • The primary bottleneck could be the database writes during peak times. Implementing a message queue can help by decoupling the write operations.

Trade-offs:

  • Consistency vs. Availability: Using eventual consistency for URL mappings in NoSQL ensures high availability but may result in stale data for a short period.
  • Push vs. Pull: Use a push model for analytics updates to ensure timely data processing.

By carefully managing these components and trade-offs, the URL shortening service can achieve the desired scalability and performance.

System designEasyGoogle (Alphabet)Data ScientistOnsite

15. You are a Data Scientist supporting a large consumer product (e.g., YouTube).

The full question

You are a Data Scientist supporting a large consumer product (e.g., YouTube). Engineering ships a change intended to reduce client-side / video-start latency by roughly 100 ms for some users, but the new code path might increase the error rate and change buffering behavior. Design and analyze the measurement program for this change.

  1. Experiment design (latency → business impact). Propose an A/B test to estimate the causal impact of reduced latency on user engagement. Define:
  • A hypothesis and a primary metric (one decision metric), explaining why it is sensitive to latency and the sensitivity-vs-business-relevance tradeoff.
  • Diagnostic metrics to localize where any change comes from (e.g., funnel steps, latency percentiles).
  • Guardrail metrics (quality / reliability / revenue) to avoid shipping a regression — in particular playback error rate and rebuffering, since the new stack may be unstable.
  1. Unit of randomization & interference. Choose user vs. device vs. session/request-level randomization and justify it. Explain how you avoid contamination and interference (sticky bucketing, CDN/cache routing, cross-device spillover).
  2. Power / MDE / duration. Describe how you would estimate sample size and runtime: what inputs you need, how you set the MDE, and how you handle heavy-tailed watch-time. Note relevant variance drivers (user heterogeneity, seasonality, outliers).
  3. Variance reduction. Give at least two techniques to reduce variance / improve sensitivity and explain when each is appropriate (e.g., CUPED, stratification, triggering, winsorization, clustered standard errors).
  4. Analysis plan & conflicting movements. Specify the estimator, how you ha

Model answer

1. Requirements & scale

Functional Requirements:

  • Implement an A/B test to measure the impact of reduced client-side video-start latency on user engagement.
  • Monitor and ensure that the new code path does not increase error rates or negatively impact buffering behavior.

Non-Functional Requirements:

  • Ensure minimal interference between test groups.
  • Maintain high reliability and availability during the test.
  • Collect data efficiently to support rapid analysis.

Back-of-the-Envelope Estimates:

  • QPS (Queries Per Second): Assume YouTube handles around 1 billion daily active users, with each user initiating approximately 5 video sessions per day. This results in roughly 60,000 QPS.
  • Storage: If each session generates 1 KB of metadata, daily storage requirements would be around 5 TB.
  • Bandwidth: Assuming each video start requires 100 KB of data transfer, the bandwidth requirement would be around 6 TB per day.

2. High-level architecture

flowchart TD
    subgraph Client
        A[User Device]
    end

    subgraph Edge/CDN
        B[Edge Server]
    end

    subgraph Load Balancer
        C[Load Balancer]
    end

    subgraph API / Services
        D[Video Start Service]
    end

    subgraph Cache
        E[Latency Cache]
    end

    subgraph Datastores
        F[User Metrics DB]
        G[Error Logs DB]
    end

    subgraph Message Queue
        H[Metrics Queue]
    end

    subgraph Workers
        I[Analytics Processor]
    end

    A -->|Video Start Request| B
    B -->|Route Request| C
    C -->|Forward Request| D
    D -->|Fetch Latency Data| E
    D -->|Log Metrics| H
    H -->|Store Metrics| F
    H -->|Store Errors| G
    F -->|Analyze Data| I
    G -->|Analyze Errors| I
Diagram

3. API design

  • POST /video/start: Initiate video playback and log start latency.
  • GET /metrics/latency: Retrieve latency metrics for analysis.
  • POST /metrics/error: Log playback errors for diagnostic purposes.

4. Data model & storage

Chosen Datastores:

  • User Metrics DB: A NoSQL database like DynamoDB for high write throughput and scalability.
  • Error Logs DB: A time-series database like InfluxDB to efficiently store and query error logs.

Key Tables:

  • UserMetrics: {userId (partition key), sessionId (sort key), latency, engagementMetrics}
  • ErrorLogs: {timestamp, errorType, userId, sessionId}

5. Deep dive

Experiment Design:

  • Hypothesis: Reducing video-start latency by 100 ms will increase user engagement, measured by average watch time per session.
  • Primary Metric: Average watch time per session, as it directly correlates with user engagement and is sensitive to latency changes.
  • Diagnostic Metrics: Latency percentiles (P50, P90, P99) to identify where latency improvements occur.
  • Guardrail Metrics: Playback error rate and rebuffering incidents to ensure quality is not compromised.

Unit of Randomization:

  • User-level Randomization: Ensures consistent experiences across sessions and devices, minimizing cross-device spillover. Sticky bucketing will be used to maintain consistent group assignments.

Power / MDE / Duration:

  • Sample Size Calculation: Use historical data to estimate variance and set a Minimum Detectable Effect (MDE) of 2% improvement in watch time. Consider user heterogeneity and seasonality in calculations.
  • Handling Heavy-tailed Watch-time: Apply log transformation to normalize data distribution and reduce variance.

Variance Reduction Techniques:

  • CUPED (Controlled Experiments Using Pre-Experiment Data): Use pre-experiment watch time as a covariate to reduce variance.
  • Stratification: Group users by region or device type to control for known sources of variance.
sequenceDiagram
    participant U as User Device
    participant E as Edge Server
    participant L as Load Balancer
    participant V as Video Start Service
    participant Q as Metrics Queue
    participant M as User Metrics DB
    participant P as Analytics Processor

    U->>E: Video Start Request
    E->>L: Route Request
    L->>V: Forward Request
    V->>Q: Log Metrics
    Q->>M: Store Metrics
    M->>P: Analyze Data
Diagram

6. Scale, bottlenecks & trade-offs

Replication and Sharding:

  • Replication: Use multi-region replication for the User Metrics DB to ensure low-latency access and high availability.
  • Sharding: Partition the User Metrics DB by userId to distribute load evenly.

Caching:

  • Implement a latency cache to store frequently accessed latency data, reducing repeated database queries.

Single Points of Failure:

  • Ensure redundancy in the Load Balancer and Edge Servers to prevent service disruption.

Trade-offs:

  • Consistency vs. Availability: Favor eventual consistency for the User Metrics DB to ensure high availability.
  • Push vs. Pull: Use a push model for real-time metrics logging to reduce latency in data collection.

By carefully designing the experiment and architecture, we can accurately measure the impact of latency improvements while maintaining system reliability and performance.

System designEasyGoogle (Alphabet)Software Engineer

16. What considerations would you make when designing a RESTful API?

Model answer

1. Requirements & scale

When designing a RESTful API, it's essential to consider both functional and non-functional requirements:

Functional Requirements:

  • CRUD Operations: The API should support Create, Read, Update, and Delete operations for resources.
  • Resource Identification: Each resource should be uniquely identifiable via a URI.
  • Statelessness: Each request from the client to the server must contain all the information needed to understand and process the request.
  • Data Formats: Support for JSON and XML as data interchange formats.

Non-Functional Requirements:

  • Scalability: The API should handle increasing loads efficiently.
  • Performance: Low latency and high throughput are critical.
  • Security: Implement authentication and authorization mechanisms.
  • Reliability: The API should be highly available and fault-tolerant.
  • Versioning: Support for versioning to ensure backward compatibility.

Back-of-the-envelope Estimates:

  • QPS (Queries Per Second): Estimate based on expected user base and operations. For example, if expecting 10,000 users with each making 5 requests per second, the API should handle 50,000 QPS.
  • Storage: Depends on the data model and expected data growth. For instance, if each resource is 1KB and there are 1 million resources, storage needs would be approximately 1GB.
  • Bandwidth: Calculate based on average response size and QPS. If the average response is 2KB, then bandwidth = 50,000 QPS * 2KB = 100MB/s.

2. High-level architecture

flowchart TD
    subgraph Client
        A[User]
    end
    subgraph Edge/CDN
        B[CDN]
    end
    subgraph Load Balancer
        C[Load Balancer]
    end
    subgraph API / Services
        D[API Gateway]
        E[Auth Service]
        F[Resource Service]
    end
    subgraph Cache
        G[Redis Cache]
    end
    subgraph Datastores
        H["SQL DB"]
        I["NoSQL DB"]
    end
    subgraph Message Queue
        J[Message Queue]
    end
    subgraph Workers
        K[Background Worker]
    end

    A -->|HTTP Request| B
    B -->|Cached Content| A
    B -->|HTTP Request| C
    C -->|Route Request| D
    D -->|Auth Check| E
    E -->|Valid/Invalid| D
    D -->|Forward Request| F
    F -->|Read/Write| G
    G -->|Cache Hit/Miss| F
    F -->|DB Query| H
    F -->|DB Query| I
    F -->|Async Task| J
    J -->|Process Task| K
Diagram

3. API design

Key endpoints for a RESTful API might include:

  • GET /resources: Retrieve a list of resources.
  • POST /resources: Create a new resource.
  • GET /resources/{id}: Retrieve a specific resource by ID.
  • PUT /resources/{id}: Update a specific resource by ID.
  • DELETE /resources/{id}: Delete a specific resource by ID.
  • GET /resources/{id}/related: Retrieve related resources.

4. Data model & storage

Chosen Datastores:

  • SQL Database: For structured data requiring ACID transactions, such as user information and resource metadata.
  • NoSQL Database: For unstructured or semi-structured data, such as logs or user-generated content.

Key Tables:

  • Users Table (SQL): UserID (Primary Key), Username, Email, PasswordHash.
  • Resources Table (SQL): ResourceID (Primary Key), UserID (Foreign Key), Data, Timestamp.
  • Logs Collection (NoSQL): LogID, UserID, Action, Timestamp.

Partition/Sharding Key:

  • UserID for user-specific data to distribute load evenly across database shards.

5. Deep dive

The core of a RESTful API is its ability to handle requests statelessly and efficiently. A typical request flow involves:

sequenceDiagram
    participant User
    participant CDN
    participant LoadBalancer
    participant APIGateway
    participant AuthService
    participant ResourceService
    participant SQLDB
    participant RedisCache

    User->>CDN: HTTP Request
    CDN-->>User: Cached Response (if available)
    CDN->>LoadBalancer: HTTP Request
    LoadBalancer->>APIGateway: Route Request
    APIGateway->>AuthService: Verify Token
    AuthService-->>APIGateway: Auth Result
    APIGateway->>ResourceService: Forward Request
    ResourceService->>RedisCache: Check Cache
    RedisCache-->>ResourceService: Cache Miss
    ResourceService->>SQLDB: Query Data
    SQLDB-->>ResourceService: Return Data
    ResourceService->>RedisCache: Update Cache
    ResourceService-->>APIGateway: Response
    APIGateway-->>User: HTTP Response
Diagram

6. Scale, bottlenecks & trade-offs

Replication and Sharding:

  • Use database replication for read scalability and high availability.
  • Shard databases based on UserID to distribute load and improve write performance.

Caching:

  • Implement caching at multiple levels (CDN, Redis) to reduce latency and load on the database.

Single Points of Failure:

  • Use redundant load balancers and database replicas to avoid single points of failure.

Trade-offs:

  • Consistency vs. Availability (CAP Theorem): Choose eventual consistency for non-critical data to improve availability.
  • Push vs. Pull: Use pull-based mechanisms for client updates to reduce server load.
  • Sync vs. Async: Use asynchronous processing for non-critical tasks to improve response times.

By carefully considering these aspects, a robust, scalable, and efficient RESTful API can be designed to meet both current and future needs.

TechnicalEasyGoogle (Alphabet)Data ScientistTechnical screen

17. What is the probability that a seven-game series goes to 7 games?

Model answer

The flow

  1. Identify the distribution: Recognize the series as a sequence of independent Bernoulli trials.
  2. Define the event: Determine the condition for the series to reach 7 games.
  3. Write the formula: Use the binomial distribution to calculate the probability.
  4. Compute the probability: Perform the arithmetic with plausible numbers.
  5. State implications: Discuss what the result implies and potential limitations.

The answer

1. Identify the distribution: A seven-game series can be modeled as a sequence of independent Bernoulli trials, where each trial represents a game and can result in either a win or a loss for a particular team.

2. Define the event: For the series to go to 7 games, each team must win exactly 3 games in the first 6 games, forcing a decisive 7th game.

3. Write the formula: The probability that the series goes to 7 games is determined by the binomial distribution: $$ P(\text{7 games}) = \binom{6}{3} \cdot p^3 \cdot (1-p)^3 $$ where $p$ is the probability of one team winning a single game.

4. Compute the probability: Assume $p = 0.5$, meaning each team has an equal chance of winning any given game. $$ P(\text{7 games}) = \binom{6}{3} \cdot (0.5)^3 \cdot (0.5)^3 $$ $$ P(\text{7 games}) = 20 \cdot (0.125) \cdot (0.125) $$ $$ P(\text{7 games}) = 20 \cdot 0.015625 $$ $$ P(\text{7 games}) = 0.3125 $$ Therefore, the probability that the series goes to 7 games is 31.25%.

5. State implications: This calculation implies that in a fair series, there is a 31.25% chance it will go to the full 7 games. This model assumes each game is independent and the teams are evenly matched. If one team is significantly stronger, the probability would decrease. Additionally, this model does not account for external factors like home-court advantage.

Why this works

  • Understanding of distributions: The interviewer is testing your ability to recognize and apply the correct statistical distribution for a given scenario.
  • Mathematical accuracy: A strong answer demonstrates precise calculation and correct application of the binomial formula.
  • Logical reasoning: Explaining the implications and limitations shows a deeper understanding of the model's assumptions.
  • Common pitfalls: Weak answers might misidentify the distribution, incorrectly compute the probability, or fail to discuss the model's assumptions and limitations.
TechnicalEasyGoogle (Alphabet)Data ScientistTechnical Screen

18. You have a single numeric observation and want to know if it was drawn from a standard normal distribution.

The full question

You have a single numeric observation and want to know if it was drawn from a standard normal distribution.

Question

Which statistical test would you apply to decide whether that single observation comes from a normal distribution? State the null and alternative hypotheses and the decision rule.

Hints

Compute a z-score and compare it to critical values of the standard normal.

Model answer

To determine if a single numeric observation comes from a standard normal distribution, we can use the concept of a z-score. Although statistical tests typically require a sample of data, with a single observation, we can still assess its likelihood of being drawn from a standard normal distribution by computing its z-score and comparing it to critical values.

Steps to Determine if the Observation is from a Standard Normal Distribution

  1. Compute the Z-Score: - For a standard normal distribution, the mean (\(\mu\)) is 0 and the standard deviation (\(\sigma\)) is 1. - The z-score for the observation \(x\) is calculated as: \[ z = \frac{x - \mu}{\sigma} = x \] - Since \(\mu = 0\) and \(\sigma = 1\), the z-score is simply the value of the observation itself.
  2. State the Hypotheses: - Null Hypothesis (\(H_0\)): The observation is from a standard normal distribution. - Alternative Hypothesis (\(H_a\)): The observation is not from a standard normal distribution.
  3. Decision Rule: - Choose a significance level (\(\alpha\)), commonly 0.05. - Determine the critical z-values for a two-tailed test at the chosen \(\alpha\). For \(\alpha = 0.05\), the critical values are approximately -1.96 and 1.96. - Decision: - If the computed z-score falls between -1.96 and 1.96, we fail to reject the null hypothesis (\(H_0\)). - If the z-score is less than -1.96 or greater than 1.96, we reject the null hypothesis (\(H_0\)).

Example

  • Suppose the observation \(x = 1.5\).
  • Compute the z-score: \(z = 1.5\).
  • Compare \(z\) to the critical values:
  • Since \(1.5\) is between -1.96 and 1.96, we fail to reject the null hypothesis.

Conclusion

  • Fail to Reject \(H_0\): The observation is consistent with being drawn from a standard normal distribution.
  • Reject \(H_0\): The observation is unlikely to have been drawn from a standard normal distribution.

This approach provides a basic method to assess a single observation's likelihood of coming from a standard normal distribution, using the properties of the z-score and critical values.

TechnicalEasyGoogle (Alphabet)

19. What is the difference between a stack and a queue?

Model answer

Difference Between a Stack and a Queue

  1. Data Structure Type: - Stack: A stack is a linear data structure that follows the Last In, First Out (LIFO) principle. This means that the last element added to the stack will be the first one to be removed. - Queue: A queue is a linear data structure that follows the First In, First Out (FIFO) principle. This implies that the first element added to the queue will be the first one to be removed.
  2. Operations: - Stack: - Push: Add an element to the top of the stack. - Pop: Remove the element from the top of the stack. - Peek/Top: Retrieve the element at the top of the stack without removing it. - Queue: - Enqueue: Add an element to the end of the queue. - Dequeue: Remove the element from the front of the queue. - Front/Peek: Retrieve the element at the front of the queue without removing it.
  3. Use Cases: - Stack: Used in scenarios like function call management (call stack), undo mechanisms in text editors, and syntax parsing. - Queue: Used in scenarios like scheduling processes in operating systems, handling requests in web servers, and breadth-first search in graphs.
  4. Implementation: - Both stacks and queues can be implemented using arrays or linked lists. However, the choice of implementation can affect the complexity of operations like insertion and deletion.
  5. Complexity: - Stack: Both push and pop operations generally have a time complexity of O(1). - Queue: Both enqueue and dequeue operations generally have a time complexity of O(1), especially when implemented using a linked list or a circular buffer.

Understanding these differences is crucial for selecting the appropriate data structure based on the specific requirements of a problem, ensuring efficient data management and processing.

TechnicalEasyGoogle (Alphabet)Data ScientistOnsite

20. In an applied DS setting, you are modeling an outcome (e.g., watch time per session, conversion, or rating) across multiple entities (e.g., users…

The full question

In an applied DS setting, you are modeling an outcome (e.g., watch time per session, conversion, or rating) across multiple entities (e.g., users, creators, regions, experiments).

  1. What is a mixed effects model?
  2. Explain the difference between fixed effects and random effects.
  3. Give an example where a mixed model is preferable to a standard regression.
  4. How do you interpret coefficients/variance components?
  5. What practical pitfalls would you watch for (identifiability, shrinkage, correlated random effects, unbalanced panels)?

Model answer

1. What is a Mixed Effects Model?

A mixed effects model is a statistical model that incorporates both fixed effects and random effects. It is used to analyze data that have multiple sources of variability or hierarchical structures. These models are particularly useful in situations where data are collected from different groups or levels, such as users, regions, or time periods, and where the observations within each group may be correlated.

2. Difference between Fixed Effects and Random Effects

  • Fixed Effects: These are effects that are constant across individuals or entities. They represent the population average effect and are used to estimate the impact of variables that are consistent across all entities. For example, in a study of watch time per session, a fixed effect might be the overall impact of a new feature introduced to all users.
  • Random Effects: These capture the variability across individuals or entities. They are used to model the random variation at different levels of the data hierarchy. For instance, in the same study, random effects could account for the variability in watch time due to differences between individual users or regions.

3. Example where a Mixed Model is Preferable

A mixed model is preferable in a scenario where you are analyzing the effectiveness of a new feature on user engagement across multiple regions and user groups. Each region might have different baseline engagement levels, and users within the same region might have correlated behaviors. A mixed effects model can account for these variations by including random effects for regions and fixed effects for the feature.

4. Interpretation of Coefficients/Variance Components

  • Coefficients of Fixed Effects: These represent the average effect of the predictors on the outcome variable. For example, a coefficient might indicate the average increase in watch time per session due to a new feature.
  • Variance Components of Random Effects: These quantify the variability attributed to the random effects. For instance, a large variance component for regions would suggest significant differences in watch time across regions.

5. Practical Pitfalls

  • Identifiability: Ensure that the model is identifiable, meaning that the parameters can be uniquely estimated from the data. This can be an issue if there are too many random effects or if the data structure is not suitable for the model.
  • Shrinkage: Random effects estimates are subject to shrinkage, where estimates are pulled towards the overall mean. This can be beneficial for reducing overfitting but may obscure true variability if not properly accounted for.
  • Correlated Random Effects: If random effects are correlated, it can complicate the interpretation and estimation of the model. Consider using a covariance structure that accounts for these correlations.
  • Unbalanced Panels: When data are missing or unevenly distributed across groups, it can lead to biased estimates. Mixed models can handle unbalanced data, but careful consideration is needed to ensure valid inferences.

In summary, mixed effects models are powerful tools for analyzing hierarchical or grouped data, allowing for both fixed and random variations. Proper interpretation and awareness of potential pitfalls are crucial for effective application.

Practice these out loud, don't memorise them

Reading an answer is not the same as being able to give one under pressure. ChannelPulse plays the interviewer, asks the follow-ups, and scores each answer with feedback and a model answer so you can hear the gap between what you said and what lands.

Get ChannelPulse Browse all questions