Giter Site home page Giter Site logo

warycat / rustgym Goto Github PK

View Code? Open in Web Editor NEW
845.0 19.0 82.0 4.71 MB

Leetcode Solutions in Rust, Advent of Code Solutions in Rust and more

Home Page: https://rustgym.com

License: MIT License

Rust 97.09% C++ 0.63% Shell 0.10% CSS 0.93% Jinja 0.92% JavaScript 0.01% C 0.01% Objective-C 0.26% Metal 0.03% GLSL 0.03%
leetcode rust solutions macros leetcode-rust algorithm interview interview-questions interview-preparation interview-practice

rustgym's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rustgym's Issues

Website requests camera and mic access

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.

Leetcode 9 Palindrome Number

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
        }
    }
}

Leetcode 7 Reverse Integer

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
        }
    }
}

_14_longest_common_prefix.rs: linting with clippy

In _14_longest_common_prefix.rs, running cargo clippy suggests:

  • replacing if strs.len() < 1 with if strs.is_empty()
  • replacing 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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.