PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates array manipulation and numeric computation skills—specifically identifying the maximum element, applying a percentage discount, and correctly handling fractional results and flooring—within the Coding & Algorithms domain.

  • medium
  • Other
  • Coding & Algorithms
  • Software Engineer

Compute total after discounting most expensive item

Company: Other

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Take-home Project

## Problem You are given: - An array `prices` of length `n`, where `prices[i]` is the price of the *i-th* item. - An integer `discountPercent` (0 to 100). A promotion applies **only to one item**: the **most expensive** item receives `discountPercent` percent off. If there are multiple items tied for the maximum price, discount any one of them (the result is the same). The discounted amount may be fractional. The final amount to pay is: \[ \left\lfloor \sum prices - (\max(prices) \cdot discountPercent/100) \right\rfloor \] Return the final amount to pay as an integer. ### Input - `prices`: array of non-negative numbers (integers or decimals) - `discountPercent`: integer in `[0, 100]` ### Output - Integer: the floored total amount to pay. ### Constraints (typical) - `1 <= n <= 2 * 10^5` - `0 <= prices[i] <= 10^9` ### Example - `prices = [100, 50, 25]`, `discountPercent = 20` - max price = 100, discount = 20 - total = floor(175 - 20) = `155`

Quick Answer: This question evaluates array manipulation and numeric computation skills—specifically identifying the maximum element, applying a percentage discount, and correctly handling fractional results and flooring—within the Coding & Algorithms domain.

Return floor(total prices minus discountPercent percent of the maximum-priced item).

Constraints

  • Inputs are Python literals matching the function signature.
  • Return a deterministic exact-match value.

Examples

Input: ([100,50,25], 20)

Expected Output: 155

Explanation: Discount 20 percent from 100.

Input: ([10,10], 50)

Expected Output: 15

Explanation: Ties for most expensive produce the same total.

Input: ([19.99,5], 10)

Expected Output: 22

Explanation: Fractional discounted totals are floored.

Hints

  1. Clarify edge cases before coding.
  2. Keep outputs deterministic when several valid answers exist.
Last updated: Jun 27, 2026

Loading coding console...

PracHub

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

  • Implement a multi-button click detector - Other (hard)
  • Return the k-th row of Pascal-like triangle - Other (medium)
  • Implement multiplication without using the multiplication operator - Other (Medium)
  • Prove reservoir sampling correctness - Other (Medium)
  • Write mini-batch gradient descent - Other (Medium)