PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep

Quick Overview

This pair of problems evaluates algorithm design and implementation skills, focusing on efficient search/optimization for constrained processing speed and manual arbitrary-precision string multiplication for very large integers.

  • medium
  • Bytedance
  • Coding & Algorithms
  • Software Engineer

Solve Search Speed and String Product

Company: Bytedance

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

You are asked to solve two coding problems. ### Problem 1: Find the Minimum Constant Processing Speed You are given an array `piles`, where `piles[i]` is the number of items in the `i`-th pile, and an integer `h`, the maximum number of hours available. Each hour, you may choose exactly one non-empty pile and process up to `k` items from that pile. If the pile has fewer than `k` items remaining, you finish that pile during the hour and do not use the remaining capacity on another pile. Return the minimum positive integer speed `k` such that all piles can be processed within `h` hours. Example: ```text Input: piles = [3, 6, 7, 11], h = 8 Output: 4 ``` Explain both a brute-force approach and an optimized approach. For the optimized approach, analyze the time complexity carefully. ### Problem 2: Compute the Product of Two Large Non-Negative Integers You are given two non-negative integers `num1` and `num2` represented as decimal strings. The integers may be too large to fit into built-in numeric types. Return their product as a decimal string. Constraints: - `num1` and `num2` contain only digits `0-9`. - Neither string contains leading zeros unless the number is exactly `"0"`. - You may not directly convert the full strings into built-in integer types. Example: ```text Input: num1 = "123", num2 = "456" Output: "56088" ``` Write several test cases, including edge cases, and explain the algorithmic complexity.

Quick Answer: This pair of problems evaluates algorithm design and implementation skills, focusing on efficient search/optimization for constrained processing speed and manual arbitrary-precision string multiplication for very large integers.

Part 1: Find the Minimum Constant Processing Speed

You are given a list of pile sizes `piles`, where `piles[i]` is the number of items in the `i`-th pile, and an integer `h` representing the maximum number of hours available. In each hour, you may choose exactly one non-empty pile and process up to `k` items from it. If a pile has fewer than `k` items left, you finish that pile during the hour, and any unused capacity is lost. Return the minimum positive integer `k` such that all piles can be processed within `h` hours. A brute-force idea is to try every speed from `1` to `max(piles)`, but that can be too slow for large inputs. Design an efficient solution.

Constraints

  • 1 <= len(piles) <= 100000
  • 1 <= piles[i] <= 1000000000
  • len(piles) <= h <= 100000000000000

Examples

Input: ([3, 6, 7, 11], 8)

Expected Output: 4

Explanation: At speed 4, the required hours are 1 + 2 + 2 + 3 = 8, which fits exactly.

Input: ([30, 11, 23, 4, 20], 5)

Expected Output: 30

Explanation: There are 5 piles and only 5 hours, so each pile must be finished in one hour. The speed must be at least the largest pile size.

Input: ([30, 11, 23, 4, 20], 6)

Expected Output: 23

Explanation: Speed 23 works in 6 hours, while speed 22 needs 7 hours.

Input: ([1], 1)

Expected Output: 1

Explanation: Single-pile edge case.

Input: ([1000000000], 2)

Expected Output: 500000000

Explanation: To finish a pile of size 1,000,000,000 in 2 hours, the minimum speed is 500,000,000.

Hints

  1. For a fixed speed `k`, the hours needed for a pile of size `p` is `ceil(p / k)`.
  2. If a speed `k` works, then every speed larger than `k` also works. That monotonic property suggests binary search.

Part 2: Compute the Product of Two Large Non-Negative Integers

You are given two non-negative integers `num1` and `num2` represented as decimal strings. The values may be too large to fit into built-in numeric types. Return their product as a decimal string. You may not directly convert the full input strings into built-in integer types. Instead, simulate multiplication the way you would do it by hand.

Constraints

  • 1 <= len(num1), len(num2) <= 200
  • `num1` and `num2` contain only characters '0' through '9'
  • Neither input has leading zeros unless the value is exactly "0"
  • You may not convert the entire strings to built-in integer types

Examples

Input: ("123", "456")

Expected Output: "56088"

Explanation: Standard example: 123 × 456 = 56088.

Input: ("0", "52")

Expected Output: "0"

Explanation: If either number is zero, the product is zero.

Input: ("9", "9")

Expected Output: "81"

Explanation: Single-digit multiplication with carry.

Input: ("999", "999")

Expected Output: "998001"

Explanation: Tests repeated carries across multiple positions.

Input: ("1", "1")

Expected Output: "1"

Explanation: Smallest non-zero edge case.

Hints

  1. The result of multiplying numbers with lengths `m` and `n` has at most `m + n` digits.
  2. When multiplying digits from right to left, each pair contributes to positions `i + j` and `i + j + 1` in a result array because of carry.
Last updated: Jun 6, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,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

  • Reverse Nodes in K-Sized Groups - Bytedance
  • Solve Stack and String Shift Problems - Bytedance (medium)
  • Find LCA With Parent Pointers - Bytedance (medium)
  • Count Target-Sum Paths in an N-ary Tree - Bytedance (hard)
  • Connect Points With Minimum Total Distance - Bytedance (medium)