PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Coding & Algorithms/Other

Compute total after discounting most expensive item

Last updated: Mar 29, 2026

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.

Related Interview 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)
Other logo
Other
Jan 21, 2026, 12:00 AM
Software Engineer
Take-home Project
Coding & Algorithms
3
0
Loading...

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:

⌊∑prices−(max⁡(prices)⋅discountPercent/100)⌋\left\lfloor \sum prices - (\max(prices) \cdot discountPercent/100) \right\rfloor⌊∑prices−(max(prices)⋅discountPercent/100)⌋

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

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

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