Welcome to your dedicated workspace for Python LeetCode-style coding challenges! This project is designed to help you refresh your coding knowledge and skills by providing a structured environment to solve problems, write code, and verify your solutions using automated tests
A structured, offline-friendly workspace of 63 LeetCode-style algorithm challenges, split evenly across basic, intermediate, and advanced tiers. Every problem follows the same shape: a stub you implement, a test that starts red, a worked reference solution, and a README explaining the approach in plain language.
algorithms/
├── pyproject.toml, uv.lock # uv-managed project (see Setup below)
├── pytest.ini
├── basic/<id>_<slug>/ 21 problems
├── intermediate/<id>_<slug>/ 21 problems
├── advanced/<id>_<slug>/ 21 problems
└── solutions/<tier>/<id>_<slug>/ reference implementations
Each problem folder (e.g. algorithms/basic/01_two_sum/) contains exactly
three things:
| File | Purpose |
|---|---|
README.md |
Problem statement, brief explanation, proposed solutions (with time/space complexity, ranked by how hard each is to code), and a link to the reference. |
<module>.py |
The stub — a function/class signature with a # TODO. This is what you implement. |
test_<module>.py |
Fails until you fill in the stub correctly. |
The matching solutions/ folder holds a fully worked reference implementation
with its own passing test.
This project uses uv instead of plain
pip/venv. Install it once (needs network):
curl -LsSf https://astral.sh/uv/install.sh | sh # macOS/LinuxThen, from algorithms/, one command creates the virtual environment and
installs pytest (also needs network the first time; fully offline after):
cd algorithms
uv syncuv run pytest # everything — expect failures until you solve them
uv run pytest basic # one tier: basic / intermediate / advanced
uv run pytest solutions # reference solutions — should always be green
uv run pytest basic/01_two_sum -v # one problem63 problems total: 21 basic, 21 intermediate, 21 advanced. All are free
(non-premium) LeetCode problems — the LeetCode number is in every problem's own
README. This same catalog (same 63 problems, same numbering) is implemented
identically in java-exercise, ts-exercise, and js-exercise.
Basic (01–21)
| # | Problem | Topics | Path |
|---|---|---|---|
| 01 | Two Sum | Array, Hash Map | algorithms/basic/01_two_sum/ |
| 02 | Valid Parentheses | Stack, String | algorithms/basic/02_valid_parentheses/ |
| 03 | Palindrome Number | Math | algorithms/basic/03_palindrome_number/ |
| 04 | Reverse String | Two Pointers, String | algorithms/basic/04_reverse_string/ |
| 05 | FizzBuzz | Math, Simulation | algorithms/basic/05_fizzbuzz/ |
| 06 | Merge Two Sorted Lists | Linked List, Recursion | algorithms/basic/06_merge_two_sorted_lists/ |
| 07 | Best Time to Buy and Sell Stock | Array, DP, Greedy | algorithms/basic/07_best_time_to_buy_and_sell_stock/ |
| 08 | Contains Duplicate | Array, Hash Set | algorithms/basic/08_contains_duplicate/ |
| 09 | Valid Anagram | Hash Map, Sorting, String | algorithms/basic/09_valid_anagram/ |
| 10 | Valid Palindrome | Two Pointers, String | algorithms/basic/10_valid_palindrome/ |
| 11 | Maximum Subarray | Array, DP, Kadane's | algorithms/basic/11_maximum_subarray/ |
| 12 | Climbing Stairs | DP, Math | algorithms/basic/12_climbing_stairs/ |
| 13 | Binary Search | Binary Search | algorithms/basic/13_binary_search/ |
| 14 | Majority Element | Array, Boyer-Moore Voting | algorithms/basic/14_majority_element/ |
| 15 | Move Zeroes | Two Pointers, Array | algorithms/basic/15_move_zeroes/ |
| 16 | Merge Sorted Array | Two Pointers, Array | algorithms/basic/16_merge_sorted_array/ |
| 17 | First Unique Character in a String | Hash Map, String | algorithms/basic/17_first_unique_character/ |
| 18 | Invert Binary Tree | Tree, BFS/DFS, Recursion | algorithms/basic/18_invert_binary_tree/ |
| 19 | Maximum Depth of Binary Tree | Tree, BFS/DFS, Recursion | algorithms/basic/19_maximum_depth_of_binary_tree/ |
| 20 | Linked List Cycle | Linked List, Two Pointers (Floyd's) | algorithms/basic/20_linked_list_cycle/ |
| 21 | Missing Number | Array, Math, Bit Manipulation | algorithms/basic/21_missing_number/ |
Intermediate (22–42)
| # | Problem | Topics | Path |
|---|---|---|---|
| 22 | Longest Substring Without Repeating Characters | Sliding Window, Hash Map | algorithms/intermediate/22_longest_substring/ |
| 23 | 3Sum | Two Pointers, Sorting | algorithms/intermediate/23_three_sum/ |
| 24 | Container With Most Water | Two Pointers, Greedy | algorithms/intermediate/24_container_with_most_water/ |
| 25 | Group Anagrams | Hash Map, String, Sorting | algorithms/intermediate/25_group_anagrams/ |
| 26 | Product of Array Except Self | Array, Prefix/Suffix | algorithms/intermediate/26_product_of_array_except_self/ |
| 27 | Top K Frequent Elements | Hash Map, Heap, Bucket Sort | algorithms/intermediate/27_top_k_frequent_elements/ |
| 28 | Merge Intervals | Array, Sorting, Intervals | algorithms/intermediate/28_merge_intervals/ |
| 29 | Search in Rotated Sorted Array | Binary Search | algorithms/intermediate/29_search_in_rotated_sorted_array/ |
| 30 | Longest Palindromic Substring | DP, Two Pointers, String | algorithms/intermediate/30_longest_palindromic_substring/ |
| 31 | Binary Tree Level Order Traversal | Tree, BFS | algorithms/intermediate/31_binary_tree_level_order/ |
| 32 | Validate Binary Search Tree | Tree, DFS, Recursion | algorithms/intermediate/32_validate_bst/ |
| 33 | Lowest Common Ancestor of a BST | Tree, BST, Recursion | algorithms/intermediate/33_lowest_common_ancestor_of_bst/ |
| 34 | Number of Islands | Grid, BFS/DFS, Union-Find | algorithms/intermediate/34_number_of_islands/ |
| 35 | Course Schedule | Graph, Topological Sort, DFS | algorithms/intermediate/35_course_schedule/ |
| 36 | Coin Change | DP | algorithms/intermediate/36_coin_change/ |
| 37 | House Robber | DP | algorithms/intermediate/37_house_robber/ |
| 38 | Longest Increasing Subsequence | DP, Binary Search | algorithms/intermediate/38_longest_increasing_subsequence/ |
| 39 | Subsets | Backtracking | algorithms/intermediate/39_subsets/ |
| 40 | Permutations | Backtracking | algorithms/intermediate/40_permutations/ |
| 41 | Kth Largest Element in an Array | Heap, Quickselect | algorithms/intermediate/41_kth_largest_element/ |
| 42 | LRU Cache | Hash Map, Doubly Linked List, Design | algorithms/intermediate/42_lru_cache/ |
Advanced (43–63)
| # | Problem | Topics | Path |
|---|---|---|---|
| 43 | Trapping Rain Water | Two Pointers, Monotonic Stack, DP | algorithms/advanced/43_trapping_rain_water/ |
| 44 | Median of Two Sorted Arrays | Binary Search, Divide & Conquer | algorithms/advanced/44_median_of_two_sorted_arrays/ |
| 45 | Merge k Sorted Lists | Heap, Linked List, Divide & Conquer | algorithms/advanced/45_merge_k_sorted_lists/ |
| 46 | Minimum Window Substring | Sliding Window, Hash Map | algorithms/advanced/46_minimum_window_substring/ |
| 47 | Sliding Window Maximum | Monotonic Deque, Sliding Window | algorithms/advanced/47_sliding_window_maximum/ |
| 48 | Word Ladder | Graph, BFS | algorithms/advanced/48_word_ladder/ |
| 49 | Implement Trie (Prefix Tree) | Trie, Design | algorithms/advanced/49_implement_trie/ |
| 50 | Word Search II | Trie, Backtracking, Grid DFS | algorithms/advanced/50_word_search_ii/ |
| 51 | Serialize and Deserialize Binary Tree | Tree, BFS/DFS, Design | algorithms/advanced/51_serialize_binary_tree/ |
| 52 | Binary Tree Maximum Path Sum | Tree, DFS, DP | algorithms/advanced/52_binary_tree_maximum_path_sum/ |
| 53 | Edit Distance | DP (2-D) | algorithms/advanced/53_edit_distance/ |
| 54 | Regular Expression Matching | DP, Recursion | algorithms/advanced/54_regular_expression_matching/ |
| 55 | Longest Valid Parentheses | Stack, DP | algorithms/advanced/55_longest_valid_parentheses/ |
| 56 | Largest Rectangle in Histogram | Monotonic Stack | algorithms/advanced/56_largest_rectangle_in_histogram/ |
| 57 | N-Queens | Backtracking | algorithms/advanced/57_n_queens/ |
| 58 | Course Schedule II | Graph, Topological Sort | algorithms/advanced/58_course_schedule_ii/ |
| 59 | Network Delay Time | Graph, Dijkstra | algorithms/advanced/59_network_delay_time/ |
| 60 | Redundant Connection | Union-Find | algorithms/advanced/60_redundant_connection/ |
| 61 | Find Median from Data Stream | Two Heaps, Design | algorithms/advanced/61_find_median_from_data_stream/ |
| 62 | Longest Consecutive Sequence | Hash Set, Array | algorithms/advanced/62_longest_consecutive_sequence/ |
| 63 | Longest Increasing Path in a Matrix | Grid DFS, Memoization | algorithms/advanced/63_longest_increasing_path_in_matrix/ |
- By number or name — use the catalog table above.
- By topic — search this README for the topic (e.g. "Backtracking", "Dijkstra", "Two Pointers") to see every problem that uses it.
- By difficulty to attempt next — work through basic before intermediate before advanced; within a tier, problems aren't ordered by difficulty, so skip around freely based on the topics you want to practice.
py-exercise/
├── python_essentials/ # 1.5 hrs - Python basics for automation
├── selenium_fundamentals/ # 2 hrs - Core Selenium with Python
├── 03_selenium_advanced/ # 2 hrs - Waits, actions, patterns
├── 04_pytest_testing/ # 1.5 hrs - PyTest framework
├── 05_page_object_model/ # 1 hr - Framework design patterns
├── 06_ci_cd_concepts/ # 1 hr - Automation in pipelines
├── 07_hands_on_practice/ # 2 hrs - Real-world scenarios
├── 08_practice_review/ # 2 hrs - Q&A and common patterns
└── requirements.txt # All dependencies
# Create virtual environment
python3 -m venv venv
# Activate virtual environment
# On macOS/Linux:
source venv/bin/activate
# On Windows:
# venv\Scripts\activate
# Install dependencies
pip install -r requirements.txtFollow the numbered directories in order. Each section contains:
- 📖 README.md - Concepts and theory
- 💻 Examples - Working code samples
- ✏️ Exercises - Practice problems
- ✅ Solutions - Solution implementations
# Run all tests
pytest
# Run specific section
pytest 04_pytest_testing/
# Run with verbose output
pytest -v
# Run with coverage
pytest --cov=.
# Run tests in parallel
pytest -n auto- Variables, lists, dicts, tuples
- Control flow (if/for/while)
- Functions and classes
- Exception handling
- List comprehensions
- File operations
- WebDriver setup
- Locators (ID, NAME, XPATH, CSS)
- Basic actions (click, send_keys, get_text)
- Browser lifecycle management
- Assertions
- Waits (implicit, explicit) ⚡ CRITICAL
- Handling alerts, frames, windows
- Mouse and keyboard actions
- Screenshots on failure
- Dynamic elements
- Test naming conventions
- Fixtures and setup/teardown
- Assertions and markers
- Test organization
- Running and reporting
- Design patterns for maintainability
- Separation of concerns
- Reusable components
- Best practices
- Headless browser execution
- Jenkins/GitHub Actions
- Test reporting
- Parallel execution
- Login automation
- Form handling
- Dynamic content
- Error handling
- Real test scenarios
- Common review questions
- Coding challenges
- Best practices
- Mental models
- The Internet - Various test scenarios
- OrangeHRM Demo - Complete application
- DemoQA - Practice elements
✅ Clean code structure
✅ Proper wait strategies (NOT time.sleep!)
✅ Reusable components
✅ Error handling
✅ Clear test organization
✅ Engineering mindset
❌ Using time.sleep() instead of explicit waits
❌ Fragile XPath locators
❌ No error handling
❌ Monolithic test scripts
❌ Poor test naming
"Java vs Python Selenium?"
Python is more concise, faster to write, excellent with PyTest and CI pipelines.
"How do you handle dynamic elements?"
Explicit waits, stable locators, avoid fragile XPath when possible.
"How do you debug flaky tests?"
Logs, screenshots, retries, environment isolation.
"Why automation fails?"
Timing issues, unstable locators, poor test design.
Day 1 (4 hrs)
- Sections 1-2: Python basics + Selenium fundamentals
Day 2 (4 hrs)
- Sections 3-4: Advanced Selenium + PyTest
Day 3 (4 hrs)
- Sections 5-8: Patterns + Practice + Review
- Complete Python Essentials
- Complete Selenium Fundamentals
- Complete Selenium Advanced
- Complete PyTest Testing
- Complete Page Object Model
- Complete CI/CD Concepts
- Complete Hands-on Practice
- Complete Practice Review
- Build mini project
- Review and refine
This is a personal learning project. Feel free to extend it with your own examples and exercises.
MIT - Feel free to use for learning purposes.
Happy practicing! 🚀
Remember: Show engineering mindset, not just memorization!