warycat / rustgym Goto Github PK
View Code? Open in Web Editor NEWLeetcode Solutions in Rust, Advent of Code Solutions in Rust and more
Home Page: https://rustgym.com
License: MIT License
Leetcode Solutions in Rust, Advent of Code Solutions in Rust and more
Home Page: https://rustgym.com
License: MIT License
When connecting to the website I get prompted to grant authorisation for camera and microphone. For a website that doesn't need any interaction with the user it seems the wrong thing to do.
Add a facebook share button for each problem. Content will be like the ones for twitter button
wasm-pack build --out-name ${version}
format the button the same way leetcode pages has
The previous solution which contains a while
loop is actually quite slow. The example solution could be optimized to be a modified version of the integer reverse digits solution that executes in O(1).
impl Solution {
pub fn is_palindrome(x: i32) -> bool {
if x < 0 {
return false
}
let x_str = x.abs()
.to_string()
.chars()
.rev()
.collect::<String>();
match x_str.parse::<i32>() {
Ok(n) => n == x,
Err(_e) => false
}
}
}
test case:
[0]
result:
-1
expected:
0
Could be simplified to:
impl Solution {
pub fn reverse(x: i32) -> i32 {
let x_str = x.abs()
.to_string()
.chars()
.rev()
.collect::<String>();
match x_str.parse::<i32>() {
Ok(n) => x.signum() * n,
Err(_e) => 0
}
}
}
test case:
[1,2]
1
result:true
expected:false
Use tantivy for indexing
The description md files can be copy paste from browser.
>=
not handling right.
it can be written using rotate_right from std::vec::Vec
https://doc.rust-lang.org/std/vec/struct.Vec.html#method.rotate_left
here's a link to your code:
https://github.com/warycat/rustgym/blob/master/rustgym/src/leetcode/_189_rotate_array.rs
In _14_longest_common_prefix.rs, running cargo clippy
suggests:
if strs.len() < 1
with if strs.is_empty()
curr_char.take().map(|ch| prefix.push(ch));
with if let Some(ch) = curr_char.take() { prefix.push(ch) };
It's not only a matter of linting, but also educational for the if let
style in rust which is not available in other popular languages like python.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.