Community Question Bundle
The Mid-Level Coding Questions Most Loops Share
Five Python questions I have now seen at four different mid-level loops in 2024 and 2025. None are tricky; all five are testing whether you can write clean code and reason about edge cases out loud.
The Mid-Level Coding Questions Most Loops Share
Five Python questions I have now seen at four different mid-level loops in 2024 and 2025. None are tricky; all five are testing whether you can write clean code and reason about edge cases out loud.
By @hugodlamini
May 13, 2026
·
Updated May 18, 2026
901 views
28
4.5 (9)
Write a function that returns the longest substring of s with no repeated characters. They want the substring, not just the length, and they will follow up by asking the runtime.
Try this
Try this. longest_unique_substring('abcabcbb') returns 'abc'. longest_unique_substring('bbbbb') returns 'b'. longest_unique_substring('pwwkew') returns 'wke' (the helper returns the first length-3 window it finds).
Given a list of intervals [(start, end), ...], return the minimum number of rooms needed to host all meetings. They are watching for whether you reach for the sort-and-sweep pattern without prompting.
Try this
Try this. min_meeting_rooms([(0, 30), (5, 10), (15, 20)]) returns 2 because (0, 30) overlaps both others. min_meeting_rooms([(7, 10), (10, 11)]) returns 1 because meetings touching at the boundary do NOT overlap. min_meeting_rooms([]) returns 0.
Implement an LRU cache with get(key) and put(key, value) both in O(1). They want the data-structure choice up front, before code.
Try this
Try this:
c = LRUCache(2)
c.put(1, 1); c.put(2, 2)
c.get(1) # -> 1, key 1 becomes MRU
c.put(3, 3) # evicts key 2 (LRU)
c.get(2) # -> -1Validate an IPv4 address string. The follow-up: extend to validate leading-zero rules (01.0.0.0 is not valid). They will probe the no-split('.')-trick path.
Try this
Try this. is_valid_ipv4('192.168.1.1') returns True. The leading-zero trap: is_valid_ipv4('01.0.0.0') returns False (multi-digit part with a leading zero), while single '0' is fine. is_valid_ipv4('256.0.0.0') returns False because 256 is out of the [0, 255] range.
Write a function that groups a list of strings into anagrams. They want O(n * k log k) and they want you to explain why a sorted-tuple key is fine.
Try this
Try this. group_anagrams(['eat', 'tea', 'tan', 'ate', 'nat', 'bat']) returns [['eat', 'tea', 'ate'], ['tan', 'nat'], ['bat']]: words land in the same group when their tuple(sorted(word)) keys match. group_anagrams([]) returns [].
