LeetCode 1777: Product's Price for Each Store Solution

Master LeetCode problem 1777 (Product's Price for Each Store), a easy challenge, with our optimized solutions in Java, C++, and Python. Explore detailed explanations, test your code in our interactive editor, and prepare for coding interviews.

1777. Product's Price for Each Store

Problem Explanation

Explanation:

To solve this problem, we can iterate over the given products list and calculate the price for each store by multiplying the base price with the corresponding multiplier for that store. We can store the prices for each store in a new list and return it as the result.

  • Time complexity: O(N) where N is the number of products in the input list.
  • Space complexity: O(N) to store the prices for each store.

:

Solution Code

import java.util.ArrayList;
import java.util.List;

class Solution {
    public List<Double> prices(List<Integer> products, List<Integer> multiplier, int n) {
        List<Double> result = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            double price = products.get(i) * multiplier.get(i) / 100.0;
            result.add(price);
        }
        return result;
    }
}

Try It Yourself

Loading code editor...

Related LeetCode Problems

Frequently Asked Questions

How to solve LeetCode 1777 (Product's Price for Each Store)?

This page provides optimized solutions for LeetCode problem 1777 (Product's Price for Each Store) in Java, C++, and Python, along with a detailed explanation and an interactive code editor to test your code.

What is the time complexity of LeetCode 1777 (Product's Price for Each Store)?

The time complexity for LeetCode 1777 (Product's Price for Each Store) varies by solution. Check the detailed explanation section for specific complexities in Java, C++, and Python implementations.

Can I run code for LeetCode 1777 on DevExCode?

Yes, DevExCode provides an interactive code editor where you can write, test, and run your code for LeetCode 1777 in Java, C++, or Python.

Back to LeetCode Solutions