refactor: rename main.rs as lib.rs
This commit is contained in:
parent
75a12ace37
commit
50d62c34be
@ -1,6 +1,4 @@
|
|||||||
fn main() {}
|
pub struct Solution;
|
||||||
|
|
||||||
struct Solution;
|
|
||||||
|
|
||||||
impl Solution {
|
impl Solution {
|
||||||
pub fn maximum69_number(num: i32) -> i32 {
|
pub fn maximum69_number(num: i32) -> i32 {
|
@ -1,8 +1,4 @@
|
|||||||
fn main() {
|
pub struct Solution;
|
||||||
println!("Hello, world!");
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Solution;
|
|
||||||
|
|
||||||
impl Solution {
|
impl Solution {
|
||||||
pub fn hamming_weight(mut n: i32) -> i32 {
|
pub fn hamming_weight(mut n: i32) -> i32 {
|
@ -1,8 +1,4 @@
|
|||||||
fn main() {
|
pub struct Solution;
|
||||||
println!("Hello, world!");
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Solution;
|
|
||||||
|
|
||||||
impl Solution {
|
impl Solution {
|
||||||
pub fn build_array(nums: Vec<i32>) -> Vec<i32> {
|
pub fn build_array(nums: Vec<i32>) -> Vec<i32> {
|
@ -1,10 +1,6 @@
|
|||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
|
||||||
fn main() {
|
pub struct Solution;
|
||||||
println!("Hello, world!");
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Solution;
|
|
||||||
|
|
||||||
impl Solution {
|
impl Solution {
|
||||||
pub fn is_happy(mut n: i32) -> bool {
|
pub fn is_happy(mut n: i32) -> bool {
|
@ -1,9 +1,3 @@
|
|||||||
use std::ops::Deref;
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
println!("Hello, world!");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Clone, Debug)]
|
#[derive(PartialEq, Eq, Clone, Debug)]
|
||||||
pub struct ListNode {
|
pub struct ListNode {
|
||||||
pub val: i32,
|
pub val: i32,
|
||||||
@ -17,7 +11,7 @@ impl ListNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Solution;
|
pub struct Solution;
|
||||||
|
|
||||||
impl Solution {
|
impl Solution {
|
||||||
pub fn reverse_list(head: Option<Box<ListNode>>) -> Option<Box<ListNode>> {
|
pub fn reverse_list(head: Option<Box<ListNode>>) -> Option<Box<ListNode>> {
|
@ -1,8 +1,4 @@
|
|||||||
fn main() {
|
pub struct Solution;
|
||||||
println!("{}", Solution::gcd(10, 25));
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Solution;
|
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Clone, Debug)]
|
#[derive(PartialEq, Eq, Clone, Debug)]
|
||||||
pub struct ListNode {
|
pub struct ListNode {
|
||||||
@ -10,13 +6,6 @@ pub struct ListNode {
|
|||||||
pub next: Option<Box<ListNode>>,
|
pub next: Option<Box<ListNode>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ListNode {
|
|
||||||
#[inline]
|
|
||||||
fn new(val: i32) -> Self {
|
|
||||||
ListNode { next: None, val }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Solution {
|
impl Solution {
|
||||||
pub fn insert_greatest_common_divisors(
|
pub fn insert_greatest_common_divisors(
|
||||||
mut head: Option<Box<ListNode>>,
|
mut head: Option<Box<ListNode>>,
|
@ -1,8 +1,4 @@
|
|||||||
fn main() {
|
pub struct Solution;
|
||||||
println!("Hello, world!");
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Solution;
|
|
||||||
|
|
||||||
impl Solution {
|
impl Solution {
|
||||||
pub fn difference_of_sums(n: i32, m: i32) -> i32 {
|
pub fn difference_of_sums(n: i32, m: i32) -> i32 {
|
@ -1,8 +1,4 @@
|
|||||||
fn main() {
|
pub struct Solution;
|
||||||
println!("{}", Solution::score_of_string("hello".to_string()));
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Solution;
|
|
||||||
|
|
||||||
impl Solution {
|
impl Solution {
|
||||||
pub fn score_of_string(s: String) -> i32 {
|
pub fn score_of_string(s: String) -> i32 {
|
@ -1,8 +1,4 @@
|
|||||||
fn main() {
|
pub struct Solution;
|
||||||
println!("Hello, world!");
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Solution;
|
|
||||||
|
|
||||||
impl Solution {
|
impl Solution {
|
||||||
pub fn is_power_of_four(mut n: i32) -> bool {
|
pub fn is_power_of_four(mut n: i32) -> bool {
|
@ -1,12 +1,6 @@
|
|||||||
use std::cmp;
|
use std::cmp;
|
||||||
|
|
||||||
fn main() {
|
pub struct Solution;
|
||||||
let x = "000".to_string();
|
|
||||||
let y = "0".to_string();
|
|
||||||
println!("{}", Solution::plus(x, y));
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Solution;
|
|
||||||
|
|
||||||
impl Solution {
|
impl Solution {
|
||||||
pub fn multiply(x: String, y: String) -> String {
|
pub fn multiply(x: String, y: String) -> String {
|
@ -1,8 +1,4 @@
|
|||||||
fn main() {
|
pub struct Solution;
|
||||||
println!("Hello, world!");
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Solution;
|
|
||||||
|
|
||||||
impl Solution {
|
impl Solution {
|
||||||
pub fn unique_paths(m: i32, n: i32) -> i32 {
|
pub fn unique_paths(m: i32, n: i32) -> i32 {
|
@ -1,11 +1,4 @@
|
|||||||
fn main() {
|
pub struct Solution;
|
||||||
println!(
|
|
||||||
"{}",
|
|
||||||
Solution::unique_paths_with_obstacles(vec![vec![0], vec![1]])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Solution;
|
|
||||||
|
|
||||||
impl Solution {
|
impl Solution {
|
||||||
pub fn unique_paths_with_obstacles(obstacle_grid: Vec<Vec<i32>>) -> i32 {
|
pub fn unique_paths_with_obstacles(obstacle_grid: Vec<Vec<i32>>) -> i32 {
|
@ -1,8 +1,4 @@
|
|||||||
fn main() {
|
pub struct Solution;
|
||||||
println!("Hello, world!");
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Solution;
|
|
||||||
|
|
||||||
impl Solution {
|
impl Solution {
|
||||||
pub fn min_path_sum(mut grid: Vec<Vec<i32>>) -> i32 {
|
pub fn min_path_sum(mut grid: Vec<Vec<i32>>) -> i32 {
|
@ -1,16 +1,10 @@
|
|||||||
fn main() {
|
pub struct Solution;
|
||||||
println!("{}", Solution::judge_point24(vec![1, 5, 9, 1]));
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Solution;
|
|
||||||
|
|
||||||
impl Solution {
|
impl Solution {
|
||||||
pub fn judge_point24(cards: Vec<i32>) -> bool {
|
pub fn judge_point24(cards: Vec<i32>) -> bool {
|
||||||
let mut stack: Vec<Vec<f64>> = vec![cards.iter().map(|&v| v as f64).collect()];
|
let mut stack: Vec<Vec<f64>> = vec![cards.iter().map(|&v| v as f64).collect()];
|
||||||
|
|
||||||
while let Some(cards) = stack.pop() {
|
while let Some(cards) = stack.pop() {
|
||||||
println!("{:?}", cards);
|
|
||||||
|
|
||||||
if cards.len() == 1 {
|
if cards.len() == 1 {
|
||||||
if (cards.first().unwrap() - 24f64).abs() < 1e-6 {
|
if (cards.first().unwrap() - 24f64).abs() < 1e-6 {
|
||||||
return true;
|
return true;
|
||||||
@ -27,7 +21,6 @@ impl Solution {
|
|||||||
let mut left_cards = cards.clone();
|
let mut left_cards = cards.clone();
|
||||||
left_cards.remove(j);
|
left_cards.remove(j);
|
||||||
left_cards.remove(i);
|
left_cards.remove(i);
|
||||||
println!("{i} {j} {:?}", left_cards);
|
|
||||||
|
|
||||||
let mut new_cards = left_cards.clone();
|
let mut new_cards = left_cards.clone();
|
||||||
new_cards.push(a + b);
|
new_cards.push(a + b);
|
@ -1,8 +1,4 @@
|
|||||||
fn main() {
|
pub struct Solution;
|
||||||
println!("Hello, world!");
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Solution;
|
|
||||||
|
|
||||||
impl Solution {
|
impl Solution {
|
||||||
pub fn new21_game(n: i32, k: i32, max_pts: i32) -> f64 {
|
pub fn new21_game(n: i32, k: i32, max_pts: i32) -> f64 {
|
@ -1,11 +1,4 @@
|
|||||||
fn main() {
|
pub struct Solution;
|
||||||
println!(
|
|
||||||
"{}",
|
|
||||||
Solution::unique_paths_iii(vec![vec![1, 0, 0, 0], vec![0, 0, 0, 0], vec![0, 0, 2, -1]])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Solution;
|
|
||||||
|
|
||||||
impl Solution {
|
impl Solution {
|
||||||
pub fn unique_paths_iii(grid: Vec<Vec<i32>>) -> i32 {
|
pub fn unique_paths_iii(grid: Vec<Vec<i32>>) -> i32 {
|
Loading…
x
Reference in New Issue
Block a user