0
0
Rest APIprogramming~10 mins

Sliding window algorithm in Rest API - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to initialize the sliding window size.

Rest API
window_size = [1]
Drag options to blanks, or click blank then click option'
A0
B5
C10
D-1
Attempts:
3 left
💡 Hint
Common Mistakes
Using zero or negative numbers for window size causes errors.
2fill in blank
medium

Complete the code to slide the window by one position.

Rest API
start = start [1] 1
Drag options to blanks, or click blank then click option'
A/
B+
C*
D-
Attempts:
3 left
💡 Hint
Common Mistakes
Using subtraction instead of addition moves the window backward.
3fill in blank
hard

Fix the error in the code to correctly calculate the window sum.

Rest API
window_sum = window_sum [1] nums[end] - nums[start - 1]
Drag options to blanks, or click blank then click option'
A+
B-
C/
D*
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-' in the blank causes incorrect calculation.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps each word to its length if length is greater than 3.

Rest API
{word: [1] for word in words if [2]
Drag options to blanks, or click blank then click option'
Alen(word)
Bword
Clen(word) > 3
Dword > 3
Attempts:
3 left
💡 Hint
Common Mistakes
Using the word itself instead of its length.
Comparing the word string to a number.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps uppercase keys to values only if values are positive.

Rest API
result = {{ [1]: [2] for k, v in data.items() if v [3] 0 }}
Drag options to blanks, or click blank then click option'
Ak.upper()
Bv
C>
Dk.lower()
Attempts:
3 left
💡 Hint
Common Mistakes
Using k.lower() instead of k.upper().
Using incorrect comparison operators.