Guided Practice Mode
Master coding patterns with a Socratic AI guide that helps you discover solutions, not just copy them.
1. Reverse a String
Write a function that reverses a string. The input string is given as an array of characters `s`. You must do this by modifying the input array **in-place** with O(1) extra memory. This is a foundational problem for understanding how data is stored in contiguous memory and how to manipulate it without allocating new buffers.
2. Palindrome Check
A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. This problem tests your ability to clean data (string manipulation) and compare it efficiently.
5. Two Sum (Unsorted)
Given an array of integers `nums` and an integer `target`, return indices of the two numbers such that they add up to `target`. You may not use the same element twice. This is the classic "Hash Map" interview question.
8. Detect Loop in Linked List
Given `head`, the head of a linked list, determine if the linked list has a cycle in it. There is a cycle if some node can be reached again by continuously following the `next` pointer. This is solved using the famous "Floyd's Tortoise and Hare" algorithm.
13. Dutch National Flag (Sort 0s, 1s, 2s)
Given an array `nums` with `n` objects colored red, white, or blue, sort them **in-place** so that objects of the same color are adjacent, with the colors in the order red, white, and blue (0, 1, and 2). This must be done in a single pass O(n) without using the library sort function.
20. Binary Search
Given an array of integers `nums` which is sorted in ascending order, and an integer `target`, write a function to search `target` in `nums`. If `target` exists, then return its index. Otherwise, return -1. You must write an algorithm with **O(log n)** runtime complexity.
19. Balanced Parentheses
Given a string `s` containing just the characters `(`, `)`, `{`, `}`, `[` and `]`, determine if the input string is valid. An input string is valid if open brackets are closed by the same type of brackets and in the correct order.
15. Find Missing Number (1 to N)
Given an array `nums` containing `n` distinct numbers in the range `[0, n]`, return the only number in the range that is missing from the array. This tests your knowledge of mathematical series and arithmetic progression.
7. First Non-Repeating Character
Given a string `s`, find the first non-repeating character in it and return its index. If it does not exist, return -1. This is a common task in processing data streams and text analysis.
18. Fibonacci Sequence
The Fibonacci numbers, commonly denoted `F(n)`, form a sequence where each number is the sum of the two preceding ones, starting from 0 and 1. Calculate `F(n)`. This problem introduces you to recurrence relations and optimization (Memoization).