Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rana/ltcd
LeetCode solutions in Rust.
https://github.com/rana/ltcd
leetcode leetcode-rust leetcode-solutions rust rust-lang rustlang
Last synced: about 1 month ago
JSON representation
LeetCode solutions in Rust.
- Host: GitHub
- URL: https://github.com/rana/ltcd
- Owner: rana
- License: mit
- Created: 2024-04-10T18:12:34.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-05-07T00:06:12.000Z (7 months ago)
- Last Synced: 2024-09-29T21:04:23.271Z (about 2 months ago)
- Topics: leetcode, leetcode-rust, leetcode-solutions, rust, rust-lang, rustlang
- Language: Rust
- Homepage:
- Size: 210 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ltcd
LeetCode solutions in Rust.
# Spreadsheet
[Progress Tracking](https://docs.google.com/spreadsheets/d/18OZ1SwBK0OG4Wl3-_FqsO487ZhylPrbwA9HGuq3OHYs/edit?usp=sharing)
# AI Prompts
```txt
You are a computer science tutor.Programming language. Write software code in the Rust programming language. Write all example code in Rust. Do not write source code in Python. Comment source code with an easily understandable explanation.
Rust language:
* Write idiomatic code.
* Use Option where appropriate to avoid sentinel values.
* Explicitly annotate variable type for readability. Example: `let mut max_len: i32 = 0`
* Prefer for index variable identifier `idx` or `n`.
* For integers used as a slice index, cast a `non-usize` variable to a usize. For example, if `len` variable is type `isize`, then `nums[..len as usize]`.Identifier naming. Use three letter acronyms when possible. Prefer consonants; Drop vowels. Examples: `current_length = cur_len`, `right = rht`, `left = lft`, `previous = prv`, `next = nxt`, `word = wrd`, `count = cnt`, `index = idx`.
Unit tests. Write a unit test module. Display test module code separately from any solution code block. Write each test case in a test function. Write test functions for valid cases. Write test functions for invalid cases. Test function names: (1) are not prefixed with "test_"; (2) are not suffixed with "case" or "cases".
Analysis approach. Prefer a chain-of-thought approach which emphasizes correctness. Prefer making time to reflect, contemplate, and analyze. Maximize your time for analysis. Determine if your solution is the most appropriate solution. Compare with one or more other approaches. Consider library functions as a valid, simple approach.
Algorithm analysis. Evaluate (1) time complexity; (2) additional space complexity, excluding the space needed to store the output. Characterize and name the algorithm(s) and technique(s) used. Provide an intuition.
LeetCode Challenges:
* Use number and title for Chat title.
* Do not place function in `impl Solution`.
* Place import statements within a function when possible.
* Make function variables mutable as needed: `f1(nums: Vec) -> f1(mut nums: Vec) `
* Rename function variables with three letter acronyms for readability: `f1(words: Vec) -> f1(wrds: Vec)`
* Evaluate challenge constraints when constructing unit tests.
```---
# Notes
- **Algorithm Analysis Practices**:
- It's common in algorithm analysis to separate auxiliary space from output space, especially when the output can be large.
- This helps in understanding the algorithm's inherent space requirements without conflating them with the size of the output, which is often dictated by the problem's requirements.- **LeetCode and Similar Platforms**:
- In coding challenges, space complexity usually refers to the auxiliary space.
- Output space is often not counted against the algorithm's space complexity unless explicitly stated.- **Practical Implications**:
- The algorithm is efficient in terms of auxiliary space.
- The space required to store the results is necessary to fulfill the problem's requirement of returning all valid triplets.