FastPrepREST API: Discounted Price
Problems/REST API: Discounted Price

REST API: Discounted Price

Expedia logoExpedia● EasyINTERNOA
QuestionExamplesConstraints

Problem statement

Source note: Updated 2026-08-01. This problem is presented as a read-only source reference because the required external HackerRank API is unavailable in FastPrep’s code-execution environment. The workspace input/output, answers, test cases, and Run/Submit results are placeholders only and do not evaluate the original task. The final code-stub note is visibly cut off in the supplied source image, so the visible text is preserved without reconstructing its missing ending.

Query an API to retrieve a product’s discounted price based on its barcode.

The API endpoint is: https://jsonmock.hackerrank.com/api/inventory?barcode={barcode}, replace {barcode}. The response contains a data field, which is either:

  • An empty array (barcode not found)
  • An array with a single object containing the item's record

For a barcode found in the system, calculate the discounted price using:

discountedPrice = price - ((discount / 100) × price)

Round the result to the nearest integer. If the barcode is not found, return -1.

Example barcode = 74001755

Querying https://jsonmock.hackerrank.com/api/inventory?barcode=74001755 returns a data array with this record:

{
  "barcode": "74001755",
  "item": "Ball Gown",
  "category": "Full Body Outfits",
  "price": 785,
  "discount": 7,
  "available": 1
}

discountPrice = 785 - (7/100 * 785) = 730.05 which rounds to 730.

Function Description Complete the getDiscountedPrice function in the editor with the following parameter:

int barcode: the item to query

Returns int: the discounted price rounded to the nearest integer or -1

Examples

Example 1

placeholder = "read-only"return = "not-applicable"

Placeholder only: This sample input, output, answer, and test result exist only for workspace compatibility. They do not evaluate the source task.

Constraints

  • There will be either 1 or 0 records in data. Note: Please review the header in the code stub to see available libraries for API requests in the selected language. Required libraries can be imported in order to

More Expedia problems

  • Scramble StringONSITE INTERVIEW · Seen Sep 2026
  • Smallest Sufficient TeamONSITE INTERVIEW · Seen Sep 2026
  • Balanced NumbersOA · Seen Aug 2026
All Expedia interview questionsSee Expedia hiring insights
Saved
class Solution {
    public String getDiscountedPrice(String placeholder) {
        // Read-only placeholder. The source task is not runnable in this workspace.
    }

}
Checking account…