This repository contains my solutions to various problems on LeetCode in Rust, with the purpose of learning and improving my Rust skills. Each solution is contained in a separate file in the src/solutions directory, named sxxxx.rs where xxxx is the problem number.
To run the tests for a specific problem, use the command cargo test solutions::sxxxx::test, where xxxx is the problem number. For example, to run the tests for problem 1, use cargo test solutions::s0001::test.
The following is a list of problems that have been solved, along with the corresponding file names in the src/solutions directory:
Problem name | file |
---|---|
Two Sum | s0001.rs |
Add Two Numbers | s0002.rs |
Longest Substring Without Repeating Characters | s0003.rs |
Longest Palindromic Substring | s0005.rs |
ZigZag Conversion | s0006.rs |
Reverse Integer | s0007.rs |
String to Integer (atoi) | s0008.rs |
Palindrome Number | s0009.rs |
Regular Expression Matching | s0010/mod.rs |
Container With Most Water | s0011.rs |
Integer to Roman | s0012.rs |
Roman to Integer | s0013.rs |
Longest Common Prefix | s0014.rs |
3Sum | s0015.rs |
Letter Combinations of a Phone Number | s0017.rs |
Remove Nth Node From End of List | s0019.rs |
Valid Parentheses | s0020.rs |
Merge Two Sorted Lists | s0021.rs |
Generate Parentheses | s0022.rs |
Merge k Sorted Lists | s0023.rs |
Reverse Nodes in k-Group | s0025.rs |
Remove Duplicates from Sorted Array | s0026.rs |
Remove Element | s0027.rs |
Implement strStr() | s0028.rs |
Divide Two Integers | s0029.rs |
Longest Valid Parentheses | s0032.rs |
Search in Rotated Sorted Array | s0033.rs |
Search Insert Position | s0035.rs |
Valid Sudoku | s0036.rs |
Sudoku Solver | s0037.rs |
Count and Say | s0038.rs |
Combination Sum | s0039.rs |
Combination Sum II | s0040.rs |
Pow(x, n) | s0050.rs |
Length of Last Word | s0058.rs |
Pascal's Triangle | s0118.rs |
Reverse Linked List | s0206.rs |
Feel free to submit a pull request if you find any errors or want to suggest an alternative solution.
These solutions are my own and may not be the most efficient or optimal solution to each problem. They are meant to be a way for me to learn and practice Rust, and I encourage you to come up with your own solutions and approaches to each problem.