Skip to content

humanalgorithm/rust_data_structures_and_algorithm_problems

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Data Structures and Algorithm Problems in Rust

I created this project to demonstrate solutions to data structure and algorithm problems. This repo provides solutions using Rust while the repo python_data_structures_and_algorithms_problems solves them using Python.

File Structure

Each folder name matches the name of a corresponding problem. Each problem can be found at https://leetcode.com/problems/{problem}

The following files are contained in each folder:

solution.rs: Solution code for solving the data structure or algorithm problem
data.rs: Data setup for testing fixtures
execute.rs: Sets up the data and calls solution code with data as parameters
description.html: Description of the given problem.

Run Instructions

Solutions can be run from Cargo using the following syntax:

cargo run -p {problem_name}

Example:

cargo run -p validate_binary_search_tree

Running Case 1...
Input data:
root: Some(RefCell { value: TreeNode { val: 2, left: Some(RefCell { value: TreeNode { val: 1, left: None, right: None } }), right: Some(RefCell { value: TreeNode { val: 3, left: None, right: None } }) } })
n: Some(RefCell { value: TreeNode { val: 2, left: Some(RefCell { value: TreeNode { val: 1, left: None, right: None } }), right: Some(RefCell { value: TreeNode { val: 3, left: None, right: None } }) } })

Result:
true

Running Case 2...
Input data:
root: Some(RefCell { value: TreeNode { val: 5, left: Some(RefCell { value: TreeNode { val: 1, left: None, right: None } }), right: Some(RefCell { value: TreeNode { val: 4, left: Some(RefCell { value: TreeNode { val: 3, left: None, right: None } }), right: Some(RefCell { value: TreeNode { val: 6, left: None, right: None } }) } }) } })
n: Some(RefCell { value: TreeNode { val: 5, left: Some(RefCell { value: TreeNode { val: 1, left: None, right: None } }), right: Some(RefCell { value: TreeNode { val: 4, left: Some(RefCell { value: TreeNode { val: 3, left: None, right: None } }), right: Some(RefCell { value: TreeNode { val: 6, left: None, right: None } }) } }) } })

Result:
false

About

Data Structures and Algorithms in Rust

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •