An open API service indexing awesome lists of open source software.

https://github.com/whisperpine/leetcode-py

LeetCode problem solutions in Rust.
https://github.com/whisperpine/leetcode-py

algorithms data-structures dsa leetcode neetcode python

Last synced: 9 days ago
JSON representation

LeetCode problem solutions in Rust.

Awesome Lists containing this project

README

          

# LeetCode Python

An ongoing list of LeetCode problem solutions in Python.

## NeetCode Roadmap

Refer to [NeetCode Roadmap](https://neetcode.io/roadmap).

## Get Started

Solutions for LeetCode problems are written in files under [./tests](./tests/)
respectively. This means that pytest can run test cases for a specific LeetCode
problem. But for comprehensive tests, you should copy the code to LeetCode live
editor and submit. See [LeetCode problem set](https://leetcode.com/problemset/).

There are several ways to run tests:

```sh
# Run all test cases.
pytest
# Run test cases in a given file.
pytest path/to/test_file.py
# Run a specific test case in a given file.
pytest path/to/test_file.py::test_function_name
```

## Table of Problems

### Array & Hash

| Problem | Difficulty | Solution |
| - | - | - |
| 1. Two Sum | Easy | [1_two_sum.py](./tests/1_two_sum.py) |
| 217. Contains Duplicate | Easy | [217_contains_duplicate.py](./tests/217_contains_duplicate.py) |
| 242. Valid Anagram | Easy | [242_valid_anagram.py](./tests/242_valid_anagram.py) |
| 49. Group Anagrams | Medium | [49_group_anagrams.py](./tests/49_group_anagrams.py) |
| 347. Top K Frequent Elements | Medium | [347_top_k_frequent_elements.py](./tests/347_top_k_frequent_elements.py) |
| 238. Product of Array Except Self | Medium | [238_product_of_array_except_self.py](./tests/238_product_of_array_except_self.py) |
| 128. Longest Consecutive Sequence | Medium | [128_longest_consecutive_sequence.py](./tests/128_longest_consecutive_sequence.py) |

### Two Pointers

| Problem | Difficulty | Solution |
| - | - | - |
| 125. Valid Palindrome | Easy | [125_valid_palindrome.py](./tests/125_valid_palindrome.py) |
| 15. 3Sum | Medium | [15_3sum.py](./tests/15_3sum.py) |

### Stack

| Problem | Difficulty | Solution |
| - | - | - |
| 20. Valid Parentheses | Easy | [20_valid_parentheses.py](./tests/20_valid_parentheses.py) |

### Binary Search

| Problem | Difficulty | Solution |
| - | - | - |
| 704. Binary Search | Easy | [704_binary_search.py](./tests/704_binary_search.py) |
| 74. Search a 2D Matrix | Medium | [74_search_a_2d_matrix.py](./tests/74_search_a_2d_matrix.py) |

### Sliding Window

| Problem | Difficulty | Solution |
| - | - | - |
| 121. Best Time to Buy and Sell Stock | Easy | [121_best_time_to_buy_and_sell_stock.py](./tests/121_best_time_to_buy_and_sell_stock.py) |
| 3. Longest Substring Without Repeating Characters | Medium | [3_longest_substring_without_repeating_characters.py](./tests/3_longest_substring_without_repeating_characters.py) |