Lecture
Coding Quiz - Finding Rotten Apples
In this coding quiz, you will write a function to find rotten apples in a basket.
You will receive a list indicating the state of apples and your task is to return a list of indices where the apples are rotten.
The apple basket is represented by a list of integers, where rotten apples are denoted as 0, and fresh apples are indicated by 1.
Write your code
def solution(apples): # Write your code here return
Constraints
-
The input list will only contain elements
0or1. -
The list will contain at least one element.
Example of inputs and outputs
-
Input:
[1, 0, 1, 0, 1] -
Output:
[1, 3]
-
Input:
[1, 0, 0, 1] -
Output:
[1, 2]
Lessons in this chapter · Practice with Common Coding Quiz Types
- 1. Coding Quiz - Finding Rotten Apples
- 2. Finding Rotten Apples Explained
- 3. Coding Quiz - Calculating the Sum of a List Recursively
- 4. Explanation for Recursively Calculating the Sum of a List
- 5. Coding Quiz - 1, 2, 3 Addition
- 6. Explanation for Adding 1, 2, 3
- 7. Coding Quiz - Flattening a 2D Array
- 8. Converting to a 1D Array Explanation
- 9. Coding Quiz - Calculate the Sum of a List Using Divide and Conquer
- 10. Explanation of Calculating the Sum of a List Using Divide and Conquer
- 11. Coding Quiz - Gym Uniform Problem
- 12. Gym Uniform Problem Explanation
- 13. Coding Quiz - List of Integers with Sum Greater than Target
- 14. Explanation of Integer List with Sum Greater Than Target
- 15. Coding Quiz - Finding Travel Routes
- 16. Finding Travel Itinerary Explanation
Lecture
AI Tutor
Design
Upload
Notes
Favorites
Help