Practice Product Price at a Given Date
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Tables: Products(product_id INT, new_price INT, change_date DATE). Products has key (product_id, change_date). Each row sets a new price on that date; the initial price is 10. Return product_id and price for every product as of 2019-08-16. Use its latest price change on or before that date, or 10 if there was none. Changes after the date have no effect. Output order is unrestricted.
Source: Product Price at a Given Date on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Products table: +------------+-----------+-------------+ | product_id | new_price | change_date | +------------+-----------+-------------+ | 1 | 20 | 2019-08-14 | | 2 | 50 | 2019-08-14 | | 1 | 30 | 2019-08-15 | | 1 | 35 | 2019-08-16 | | 2 | 65 | 2019-08-17 | | 3 | 20 | 2019-08-18 | +------------+-----------+-------------+
+------------+-------+ | product_id | price | +------------+-------+ | 2 | 50 | | 1 | 35 | | 3 | 10 | +------------+-------+
Related LeetCode Problems
Practice more problems similar to Product Price at a Given Date.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.