Skip to main content
Back to problems
Leetcode
Easy
Arrays
Recyclable And Low Fat Products

Filter products that are both recyclable and low fat.

Acceptance 100%
Problem Statement

Problem

You are given a table of products. Each product has information including whether it is recyclable and whether it is low fat. Return the identifiers of all products that satisfy both of these conditions:

  • the product is recyclable
  • the product is low fat

The answer can be returned in any order.

Goal

Write a query that selects only the rows meeting both conditions and outputs the product ids.

Input Format

A table of products with at least these columns:

  • product_id
  • low_fats
  • recyclable

Each of low_fats and recyclable uses a binary indicator.

Output Format

A result table with a single column:

  • product_id

Include only rows where low_fats = 'Y' and recyclable = 'Y'.

Constraints

  • Return each qualifying product_id once.
  • The output order does not matter.
  • This is a simple filtering query.
Examples
Sample cases returned by the problem API.

Example 1

Input

Products table:
+-------------+----------+------------+
| product_id  | low_fats | recyclable |
+-------------+----------+------------+
| 0           | Y        | N          |
| 1           | Y        | Y          |
| 2           | N        | Y          |
| 3           | Y        | Y          |
+-------------+----------+------------+

Output

+-------------+
| product_id  |
+-------------+
| 1           |
| 3           |
+-------------+

Explanation

Only products 1 and 3 are both low fat and recyclable.

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.