Practice Arena

Python Coding Challenges

Write real Python in the browser. Instant feedback. From beginner to expert.

875 challenges 536 easy 303 medium 36 hard
Two Pointers & Sliding Window medium

Character Replacement Window

Given a string and a number k, find the length of the longest substring that can be made uniform by replacing at most k characters.

sliding-window two-pointers strings
+30 pts 25m
Two Pointers & Sliding Window medium

Count Nice Subarrays

Given an array of integers, count the number of contiguous subarrays that contain exactly k odd numbers.

sliding-window two-pointers subarray
+25 pts 25m
Two Pointers & Sliding Window hard

Subarrays with K different ints

Count the number of contiguous subarrays that contain exactly K distinct integers.

sliding-window two-pointers hashmap
+40 pts 40m
Two Pointers & Sliding Window easy

Reduce array to zero

Given an array of non-negative integers, each operation chooses two indices and subtracts 1 from each if both are positive. Return the minimum number of operations to reduce the array to all zeros, or -1 if impossible.

two-pointers arrays greedy
+10 pts 15m
Two Pointers & Sliding Window medium

Closest Three Sum

Given an array of integers and a target, return the sum of three numbers that is closest to the target.

sorting two-pointers array
+20 pts 20m
Two Pointers & Sliding Window medium

Fruit into Baskets

Given an array of integers representing fruit types, return the maximum number of fruits you can collect in a contiguous subarray with at most two distinct types.

sliding-window two-pointers hash-map
+25 pts 25m
Two Pointers & Sliding Window medium

Binary Subarray with Sum

Given a binary list and a goal sum, count the number of subarrays that add up to that goal.

sliding-window two-pointers subarray
+20 pts 20m
Two Pointers & Sliding Window medium

Boats to Save People – Two Pointer

Implement a function that returns the minimum number of boats needed to rescue everyone, given a weight limit and each boat carrying at most two people.

two-pointers sorting greedy
+25 pts 30m
Two Pointers & Sliding Window medium

Count Nice Subarrays

Count subarrays that contain exactly k odd numbers.

sliding-window two-pointers counting
+25 pts 30m

Showing 9 challenges · Two Pointers & Sliding Window

Two Pointers & Sliding Window — Python coding challenges

What you will find here

This page lists two pointers & sliding window challenges — real Python problems you solve in the browser IDE with instant test feedback. Each challenge includes a clear brief, starter code, and automated checks.

Challenges vs tutorials and quizzes

Challenges test what you can build under constraints. For guided teaching, use our Python tutorials. For quick checks, try quizzes or copy snippets from code samples.