PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Snowflake

Maximize revenue by choosing one query type

Last updated: Mar 29, 2026

Quick Overview

This question evaluates optimization and numerical reasoning skills, specifically selecting a single repetitive action to maximize aggregate revenue under a tight time budget while handling integer division, large numeric bounds, and deterministic tie-breaking.

  • hard
  • Snowflake
  • Coding & Algorithms
  • Software Engineer

Maximize revenue by choosing one query type

Company: Snowflake

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Technical Screen

You are given a virtual warehouse that can execute queries. There are **n** query types, and you must choose **exactly one** query type to run repeatedly for at most **k minutes**. For query type `i`: - Each run takes `time[i]` minutes (a positive integer). - Each run yields `profit[i]` revenue (a non-negative integer). - You may run the chosen query type any number of times back-to-back as long as total time does not exceed `k`. ### Task Return: 1. The **maximum total revenue** achievable within `k` minutes. 2. The **chosen query type index** (0-based) that achieves this maximum. If multiple query types yield the same maximum revenue, return the **smallest index**. ### Input - Integer `k` - Arrays `time[0..n-1]`, `profit[0..n-1]` ### Output - `(maxRevenue, bestIndex)` ### Constraints (typical) - `1 <= n <= 2e5` - `1 <= k <= 1e18` - `1 <= time[i] <= 1e18` - `0 <= profit[i] <= 1e18` ### Notes The chosen query type can be run `floor(k / time[i])` times.

Quick Answer: This question evaluates optimization and numerical reasoning skills, specifically selecting a single repetitive action to maximize aggregate revenue under a tight time budget while handling integer division, large numeric bounds, and deterministic tie-breaking.

Related Interview Questions

  • Solve Array Distance and Wiki Navigation - Snowflake (medium)
  • Implement Document Predicate APIs - Snowflake (medium)
  • Find Shortest Wiki Click Path - Snowflake (medium)
  • Schedule prerequisite classes with retakes - Snowflake (easy)
  • Solve three coding rounds - Snowflake (medium)
Snowflake logo
Snowflake
Jan 1, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
7
0
Loading...

You are given a virtual warehouse that can execute queries. There are n query types, and you must choose exactly one query type to run repeatedly for at most k minutes.

For query type i:

  • Each run takes time[i] minutes (a positive integer).
  • Each run yields profit[i] revenue (a non-negative integer).
  • You may run the chosen query type any number of times back-to-back as long as total time does not exceed k .

Task

Return:

  1. The maximum total revenue achievable within k minutes.
  2. The chosen query type index (0-based) that achieves this maximum.

If multiple query types yield the same maximum revenue, return the smallest index.

Input

  • Integer k
  • Arrays time[0..n-1] , profit[0..n-1]

Output

  • (maxRevenue, bestIndex)

Constraints (typical)

  • 1 <= n <= 2e5
  • 1 <= k <= 1e18
  • 1 <= time[i] <= 1e18
  • 0 <= profit[i] <= 1e18

Notes

The chosen query type can be run floor(k / time[i]) times.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Snowflake•More Software Engineer•Snowflake Software Engineer•Snowflake Coding & Algorithms•Software Engineer Coding & Algorithms
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.