An open API service indexing awesome lists of open source software.

https://github.com/warycat/rustgym

Leetcode Solutions in Rust, Advent of Code Solutions in Rust and more
https://github.com/warycat/rustgym

advent-of-code algorithm graph hackerrank hackerrank-solutions interview interview-practice interview-preparation interview-questions leetcode leetcode-rust leetcode-solutions macros rust solutions trie tutorial

Last synced: about 1 year ago
JSON representation

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

Awesome Lists containing this project

README

          

# [RUST GYM](http://rustgym.com) Rust Solutions [![Docs Status](https://docs.rs/rustgym/badge.svg)](https://docs.rs/rustgym) [![Rust](https://github.com/warycat/rustgym/workflows/Rust/badge.svg)](https://github.com/warycat/rustgym/actions)

## [Leetcode Solutions in Rust](#leetcode)
## [AdventOfCode Solutions in Rust](#adventofcode)
## [Google Solutions in Rust](#google)

This project demonstrates how to create **Data Structures** and to implement **Algorithms** using programming language **Rust**
All the solutions here are crafted with love and their performance beats 99% of other solutions on the leetcode website. Tutorial videos will be added later.

### Please subscribe to our [RUST GYM Youtube Channel](https://www.youtube.com/channel/UCV9HzRLPKjI8SttaIYOygsw) for future videos.

Data Structures

- Stack & Queue ( Vec, VecDeque )
- Linked List ( Option> )
- Hash Tables ( HashMap, HashSet )
- Tree Tables ( BTreeMap, BTreeSet )
- Binary Search Tree ( Option>> )
- Binary Heaps & Priority Queue ( BinaryHeap )
- Graphs ( Vec> )
- Union Find ( UnionFind )
- Trie ( Trie )

Algorithms

- Bit Manipulation & Numbers
- Stability in Sorting
- Heapsort
- Binary Search
- Kth Smallest Elements
- Permutations
- Subsets
- BFS Graph
- DFS Graph
- Dijkstra’s Algorithm
- Tree Traversals
- BFS
- DFS
- in-order
- pre-order
- post-order
- Topological Sort
- Detect cycle in an undirected graph
- Detect a cycle in a directed graph
- Count connected components in a graph
- Find strongly connected components in a graph



id
Leetcode
Level





1


Two Sum

Easy



9


Palindrome Number

Easy



13


Roman to Integer

Easy



14


Longest Common Prefix

Easy



20


Valid Parentheses

Easy



21


Merge Two Sorted Lists

Easy



26


Remove Duplicates from Sorted Array

Easy



27


Remove Element

Easy



28


Implement strStr()

Easy



35


Search Insert Position

Easy



53


Maximum Subarray

Easy



58


Length of Last Word

Easy



66


Plus One

Easy



67


Add Binary

Easy



69


Sqrt(x)

Easy



70


Climbing Stairs

Easy



83


Remove Duplicates from Sorted List

Easy



88


Merge Sorted Array

Easy



94


Binary Tree Inorder Traversal

Easy



100


Same Tree

Easy



101


Symmetric Tree

Easy



104


Maximum Depth of Binary Tree

Easy



108


Convert Sorted Array to Binary Search Tree

Easy



110


Balanced Binary Tree

Easy



111


Minimum Depth of Binary Tree

Easy



112


Path Sum

Easy



118


Pascal's Triangle

Easy



119


Pascal's Triangle II

Easy



121


Best Time to Buy and Sell Stock

Easy



125


Valid Palindrome

Easy



136


Single Number

Easy



141


Linked List Cycle

Easy



144


Binary Tree Preorder Traversal

Easy



145


Binary Tree Postorder Traversal

Easy



155


Min Stack

Easy



157


Read N Characters Given Read4

Easy



160


Intersection of Two Linked Lists

Easy



163


Missing Ranges

Easy



167


Two Sum II - Input Array Is Sorted

Easy



168


Excel Sheet Column Title

Easy



169


Majority Element

Easy



170


Two Sum III - Data structure design

Easy



171


Excel Sheet Column Number

Easy



190


Reverse Bits

Easy



191


Number of 1 Bits

Easy



202


Happy Number

Easy



203


Remove Linked List Elements

Easy



205


Isomorphic Strings

Easy



206


Reverse Linked List

Easy



217


Contains Duplicate

Easy



219


Contains Duplicate II

Easy



225


Implement Stack using Queues

Easy



226


Invert Binary Tree

Easy



228


Summary Ranges

Easy



231


Power of Two

Easy



232


Implement Queue using Stacks

Easy



234


Palindrome Linked List

Easy



235


Lowest Common Ancestor of a Binary Search Tree

Easy



237


Delete Node in a Linked List

Easy



242


Valid Anagram

Easy



243


Shortest Word Distance

Easy



246


Strobogrammatic Number

Easy



252


Meeting Rooms

Easy



257


Binary Tree Paths

Easy



258


Add Digits

Easy



263


Ugly Number

Easy



266


Palindrome Permutation

Easy



268


Missing Number

Easy



270


Closest Binary Search Tree Value

Easy



278


First Bad Version

Easy



283


Move Zeroes

Easy



290


Word Pattern

Easy



292


Nim Game

Easy



293


Flip Game

Easy



303


Range Sum Query - Immutable

Easy



326


Power of Three

Easy



338


Counting Bits

Easy



342


Power of Four

Easy



344


Reverse String

Easy



345


Reverse Vowels of a String

Easy



346


Moving Average from Data Stream

Easy



349


Intersection of Two Arrays

Easy



350


Intersection of Two Arrays II

Easy



359


Logger Rate Limiter

Easy



367


Valid Perfect Square

Easy



374


Guess Number Higher or Lower

Easy



383


Ransom Note

Easy



387


First Unique Character in a String

Easy



389


Find the Difference

Easy



392


Is Subsequence

Easy



401


Binary Watch

Easy



404


Sum of Left Leaves

Easy



405


Convert a Number to Hexadecimal

Easy



408


Valid Word Abbreviation

Easy



409


Longest Palindrome

Easy



412


Fizz Buzz

Easy



414


Third Maximum Number

Easy



415


Add Strings

Easy



422


Valid Word Square

Easy



434


Number of Segments in a String

Easy



441


Arranging Coins

Easy



448


Find All Numbers Disappeared in an Array

Easy



455


Assign Cookies

Easy



459


Repeated Substring Pattern

Easy



461


Hamming Distance

Easy



463


Island Perimeter

Easy



476


Number Complement

Easy



482


License Key Formatting

Easy



485


Max Consecutive Ones

Easy



492


Construct the Rectangle

Easy



495


Teemo Attacking

Easy



496


Next Greater Element I

Easy



500


Keyboard Row

Easy



501


Find Mode in Binary Search Tree

Easy



504


Base 7

Easy



506


Relative Ranks

Easy



507


Perfect Number

Easy



509


Fibonacci Number

Easy



520


Detect Capital

Easy



521


Longest Uncommon Subsequence I

Easy



530


Minimum Absolute Difference in BST

Easy



541


Reverse String II

Easy



543


Diameter of Binary Tree

Easy



551


Student Attendance Record I

Easy



557


Reverse Words in a String III

Easy



559


Maximum Depth of N-ary Tree

Easy



561


Array Partition I

Easy



563


Binary Tree Tilt

Easy



566


Reshape the Matrix

Easy



572


Subtree of Another Tree

Easy



575


Distribute Candies

Easy



589


N-ary Tree Preorder Traversal

Easy



590


N-ary Tree Postorder Traversal

Easy



594


Longest Harmonious Subsequence

Easy



598


Range Addition II

Easy



599


Minimum Index Sum of Two Lists

Easy



604


Design Compressed String Iterator

Easy



605


Can Place Flowers

Easy



606


Construct String from Binary Tree

Easy



617


Merge Two Binary Trees

Easy



628


Maximum Product of Three Numbers

Easy



637


Average of Levels in Binary Tree

Easy



643


Maximum Average Subarray I

Easy



645


Set Mismatch

Easy



653


Two Sum IV - Input is a BST

Easy



657


Robot Return to Origin

Easy



661


Image Smoother

Easy



671


Second Minimum Node In a Binary Tree

Easy



674


Longest Continuous Increasing Subsequence

Easy



680


Valid Palindrome II

Easy



682


Baseball Game

Easy



693


Binary Number with Alternating Bits

Easy



696


Count Binary Substrings

Easy



697


Degree of an Array

Easy



700


Search in a Binary Search Tree

Easy



703


Kth Largest Element in a Stream

Easy



704


Binary Search

Easy



705


Design HashSet

Easy



706


Design HashMap

Easy



709


To Lower Case

Easy



716


Max Stack

Easy



717


1-bit and 2-bit Characters

Easy



724


Find Pivot Index

Easy



728


Self Dividing Numbers

Easy



733


Flood Fill

Easy



734


Sentence Similarity

Easy



744


Find Smallest Letter Greater Than Target

Easy



746


Min Cost Climbing Stairs

Easy



747


Largest Number At Least Twice of Others

Easy



748


Shortest Completing Word

Easy



760


Find Anagram Mappings

Easy



762


Prime Number of Set Bits in Binary Representation

Easy



766


Toeplitz Matrix

Easy



771


Jewels and Stones

Easy



783


Minimum Distance Between BST Nodes

Easy



796


Rotate String

Easy



800


Similar RGB Color

Easy



804


Unique Morse Code Words

Easy



806


Number of Lines To Write String

Easy



812


Largest Triangle Area

Easy



819


Most Common Word

Easy



821


Shortest Distance to a Character

Easy



824


Goat Latin

Easy



830


Positions of Large Groups

Easy



832


Flipping an Image

Easy



836


Rectangle Overlap

Easy



844


Backspace String Compare

Easy



852


Peak Index in a Mountain Array

Easy



859


Buddy Strings

Easy



860


Lemonade Change

Easy



867


Transpose Matrix

Easy



868


Binary Gap

Easy



872


Leaf-Similar Trees

Easy



876


Middle of the Linked List

Easy



883


Projection Area of 3D Shapes

Easy



884


Uncommon Words from Two Sentences

Easy



888


Fair Candy Swap

Easy



892


Surface Area of 3D Shapes

Easy



896


Monotonic Array

Easy



897


Increasing Order Search Tree

Easy



905


Sort Array By Parity

Easy



908


Smallest Range I

Easy



914


X of a Kind in a Deck of Cards

Easy



917


Reverse Only Letters

Easy



922


Sort Array By Parity II

Easy



925


Long Pressed Name

Easy



929


Unique Email Addresses

Easy



933


Number of Recent Calls

Easy



937


Reorder Data in Log Files

Easy



938


Range Sum of BST

Easy



941


Valid Mountain Array

Easy



942


DI String Match

Easy



944


Delete Columns to Make Sorted

Easy



953


Verifying an Alien Dictionary

Easy



961


N-Repeated Element in Size 2N Array

Easy



965


Univalued Binary Tree

Easy



976


Largest Perimeter Triangle

Easy



977


Squares of a Sorted Array

Easy



989


Add to Array-Form of Integer

Easy



993


Cousins in Binary Tree

Easy



997


Find the Town Judge

Easy



999


Available Captures for Rook

Easy



1002


Find Common Characters

Easy



1005


Maximize Sum Of Array After K Negations

Easy



1009


Complement of Base 10 Integer

Easy



1013


Partition Array Into Three Parts With Equal Sum

Easy



1018


Binary Prefix Divisible By 5

Easy



1021


Remove Outermost Parentheses

Easy



1022


Sum of Root To Leaf Binary Numbers

Easy



1025


Divisor Game

Easy



1030


Matrix Cells in Distance Order

Easy



1037


Valid Boomerang

Easy



1046


Last Stone Weight

Easy



1047


Remove All Adjacent Duplicates In String

Easy



1051


Height Checker

Easy



1056


Confusing Number

Easy



1064


Fixed Point

Easy



1065


Index Pairs of a String

Easy



1071


Greatest Common Divisor of Strings

Easy



1078


Occurrences After Bigram

Easy



1085


Sum of Digits in the Minimum Number

Easy



1086


High Five

Easy



1089


Duplicate Zeros

Easy



1099


Two Sum Less Than K

Easy



1103


Distribute Candies to People

Easy



1108


Defanging an IP Address

Easy



1114


Print in Order

Easy



1118


Number of Days in a Month

Easy



1119


Remove Vowels from a String

Easy



1122


Relative Sort Array

Easy



1128


Number of Equivalent Domino Pairs

Easy



1133


Largest Unique Number

Easy



1134


Armstrong Number

Easy



1137


N-th Tribonacci Number

Easy



1150


Check If a Number Is Majority Element in a Sorted Array

Easy



1154


Day of the Year

Easy



1160


Find Words That Can Be Formed by Characters

Easy



1165


Single-Row Keyboard

Easy



1175


Prime Arrangements

Easy



1176


Diet Plan Performance

Easy



1180


Count Substrings with Only One Distinct Letter

Easy



1184


Distance Between Bus Stops

Easy



1185


Day of the Week

Easy



1189


Maximum Number of Balloons

Easy



1196


How Many Apples Can You Put into the Basket

Easy



1200


Minimum Absolute Difference

Easy



1207


Unique Number of Occurrences

Easy



1213


Intersection of Three Sorted Arrays

Easy



1217


Minimum Cost to Move Chips to The Same Position

Easy



1221


Split a String in Balanced Strings

Easy



1228


Missing Number In Arithmetic Progression

Easy



1232


Check If It Is a Straight Line

Easy



1243


Array Transformation

Easy



1252


Cells with Odd Values in a Matrix

Easy



1260


Shift 2D Grid

Easy



1266


Minimum Time Visiting All Points

Easy



1271


Hexspeak

Easy



1275


Find Winner on a Tic Tac Toe Game

Easy



1279


Traffic Light Controlled Intersection

Easy



1281


Subtract the Product and Sum of Digits of an Integer

Easy



1287


Element Appearing More Than 25% In Sorted Array

Easy



1290


Convert Binary Number in a Linked List to Integer

Easy



1295


Find Numbers with Even Number of Digits

Easy



1299


Replace Elements with Greatest Element on Right Side

Easy



1304


Find N Unique Integers Sum up to Zero

Easy



1309


Decrypt String from Alphabet to Integer Mapping

Easy



1313


Decompress Run-Length Encoded List

Easy



1317


Convert Integer to the Sum of Two No-Zero Integers

Easy



1323


Maximum 69 Number

Easy



1331


Rank Transform of an Array

Easy



1332


Remove Palindromic Subsequences

Easy



1337


The K Weakest Rows in a Matrix

Easy



1342


Number of Steps to Reduce a Number to Zero

Easy



1346


Check If N and Its Double Exist

Easy



1351


Count Negative Numbers in a Sorted Matrix

Easy



1356


Sort Integers by The Number of 1 Bits

Easy



1360


Number of Days Between Two Dates

Easy



1365


How Many Numbers Are Smaller Than the Current Number

Easy



1370


Increasing Decreasing String

Easy



1374


Generate a String With Characters That Have Odd Counts

Easy



1380


Lucky Numbers in a Matrix

Easy



1385


Find the Distance Value Between Two Arrays

Easy



1389


Create Target Array in the Given Order

Easy



1394


Find Lucky Integer in an Array

Easy



1399


Count Largest Group

Easy



1403


Minimum Subsequence in Non-Increasing Order

Easy



1408


String Matching in an Array

Easy



1413


Minimum Value to Get Positive Step by Step Sum

Easy



1417


Reformat The String

Easy



1422


Maximum Score After Splitting a String

Easy



1426


Counting Elements

Easy



1427


Perform String Shifts

Easy



1431


Kids With the Greatest Number of Candies

Easy



1436


Destination City

Easy



1437


Check If All 1's Are at Least Length K Places Away

Easy



1441


Build an Array With Stack Operations

Easy



1446


Consecutive Characters

Easy



1450


Number of Students Doing Homework at a Given Time

Easy



1455


Check If a Word Occurs As a Prefix of Any Word in a Sentence

Easy



1460


Make Two Arrays Equal by Reversing Sub-arrays

Easy



1464


Maximum Product of Two Elements in an Array

Easy



1469


Find All The Lonely Nodes

Easy



1470


Shuffle the Array

Easy



1474


Delete N Nodes After M Nodes of a Linked List

Easy



1475


Final Prices With a Special Discount in a Shop

Easy



1480


Running Sum of 1d Array

Easy



1486


XOR Operation in an Array

Easy



1491


Average Salary Excluding the Minimum and Maximum Salary

Easy



1496


Path Crossing

Easy



1502


Can Make Arithmetic Progression From Sequence

Easy



1507


Reformat Date

Easy



1512


Number of Good Pairs

Easy



1518


Water Bottles

Easy



1523


Count Odd Numbers in an Interval Range

Easy



1528


Shuffle String

Easy



1534


Count Good Triplets

Easy



1539


Kth Missing Positive Number

Easy



1544


Make The String Great

Easy



1550


Three Consecutive Odds

Easy



1556


Thousand Separator

Easy



1560


Most Visited Sector in a Circular Track

Easy



1566


Detect Pattern of Length M Repeated K or More Times

Easy



1572


Matrix Diagonal Sum

Easy



1576


Replace All ?'s to Avoid Consecutive Repeating Characters

Easy



1582


Special Positions in a Binary Matrix

Easy



1588


Sum of All Odd Length Subarrays

Easy



1592


Rearrange Spaces Between Words

Easy



1598


Crawler Log Folder

Easy



1603


Design Parking System

Easy



1608


Special Array With X Elements Greater Than or Equal X

Easy



1614


Maximum Nesting Depth of the Parentheses

Easy



1619


Mean of Array After Removing Some Elements

Easy



1624


Largest Substring Between Two Equal Characters

Easy



1629


Slowest Key

Easy



1636


Sort Array by Increasing Frequency

Easy



1640


Check Array Formation Through Concatenation

Easy



1646


Get Maximum in Generated Array

Easy



1652


Defuse the Bomb

Easy



1656


Design an Ordered Stream

Easy



1662


Check If Two String Arrays are Equivalent

Easy



1668


Maximum Repeating Substring

Easy



1672


Richest Customer Wealth

Easy



1678


Goal Parser Interpretation

Easy



1684


Count the Number of Consistent Strings

Easy



1688


Count of Matches in Tournament

Easy



1694


Reformat Phone Number

Easy



1700


Number of Students Unable to Eat Lunch

Easy



1704


Determine if String Halves Are Alike

Easy



1708


Largest Subarray Length K

Easy



1710


Maximum Units on a Truck

Easy



1716


Calculate Money in Leetcode Bank

Easy



1720


Decode XORed Array

Easy



1725


Number Of Rectangles That Can Form The Largest Square

Easy



1732


Find the Highest Altitude

Easy



1736


Latest Time by Replacing Hidden Digits

Easy



1742


Maximum Number of Balls in a Box

Easy



1748


Sum of Unique Elements

Easy



1752


Check if Array Is Sorted and Rotated

Easy



1758


Minimum Changes To Make Alternating Binary String

Easy



1763


Longest Nice Substring

Easy



1768


Merge Strings Alternately

Easy



1773


Count Items Matching a Rule

Easy



1779


Find Nearest Point That Has the Same X or Y Coordinate

Easy



1784


Check if Binary String Has at Most One Segment of Ones

Easy



1790


Check if One String Swap Can Make Strings Equal

Easy



1791


Find Center of Star Graph

Easy



1796


Second Largest Digit in a String

Easy



1800


Maximum Ascending Subarray Sum

Easy



1805


Number of Different Integers in a String

Easy



1812


Determine Color of a Chessboard Square

Easy



1816


Truncate Sentence

Easy



1822


Sign of the Product of an Array

Easy



1826


Faulty Sensor

Easy



1827


Minimum Operations to Make the Array Increasing

Easy



1832


Check if the Sentence Is Pangram

Easy



1837


Sum of Digits in Base K

Easy



1844


Replace All Digits with Characters

Easy



1848


Minimum Distance to the Target Element

Easy



1854


Maximum Population Year

Easy



1859


Sorting the Sentence

Easy



1863


Sum of All Subset XOR Totals

Easy



1869


Longer Contiguous Segments of Ones than Zeros

Easy



1876


Substrings of Size Three with Distinct Characters

Easy



1880


Check if Word Equals Summation of Two Words

Easy



1886


Determine Whether Matrix Can Be Obtained By Rotation

Easy



1893


Check if All the Integers in a Range Are Covered

Easy



1897


Redistribute Characters to Make All Strings Equal

Easy



1903


Largest Odd Number in String

Easy



1909


Remove One Element to Make the Array Strictly Increasing

Easy



1913


Maximum Product Difference Between Two Pairs

Easy



1920


Build Array from Permutation

Easy



1925


Count Square Sum Triples

Easy



1929


Concatenation of Array

Easy



1933


Check if String Is Decomposable Into Value-Equal Substrings

Easy



1935


Maximum Number of Words You Can Type

Easy



1941


Check if All Characters Have Equal Number of Occurrences

Easy



1945


Sum of Digits of String After Convert

Easy



1952


Three Divisors

Easy



1957


Delete Characters to Make Fancy String

Easy



1961


Check If String Is a Prefix of Array

Easy



1967


Number of Strings That Appear as Substrings in Word

Easy



1971


Find if Path Exists in Graph

Easy



1974


Minimum Time to Type Word Using Special Typewriter

Easy



1979


Find Greatest Common Divisor of Array

Easy



1984


Minimum Difference Between Highest and Lowest of K Scores

Easy



1991


Find the Middle Index in Array

Easy



1995


Count Special Quadruplets

Easy



2000


Reverse Prefix of Word

Easy



2006


Count Number of Pairs With Absolute Difference K

Easy



2011


Final Value of Variable After Performing Operations

Easy



2016


Maximum Difference Between Increasing Elements

Easy



2022


Convert 1D Array Into 2D Array

Easy



2027


Minimum Moves to Convert String

Easy



2032


Two Out of Three

Easy



2037


Minimum Number of Moves to Seat Everyone

Easy



2042


Check if Numbers Are Ascending in a Sentence

Easy



2047


Number of Valid Words in a Sentence

Easy



2053


Kth Distinct String in an Array

Easy



2057


Smallest Index With Equal Value

Easy



2062


Count Vowel Substrings of a String

Easy



2068


Check Whether Two Strings are Almost Equivalent

Easy



2073


Time Needed to Buy Tickets

Easy



2078


Two Furthest Houses With Different Colors

Easy



2085


Count Common Words With One Occurrence

Easy



2089


Find Target Indices After Sorting Array

Easy



2094


Finding 3-Digit Even Numbers

Easy



2099


Find Subsequence of Length K With the Largest Sum

Easy



2103


Rings and Rods

Easy



2108


Find First Palindromic String in the Array

Easy



2114


Maximum Number of Words Found in Sentences

Easy



2119


A Number After a Double Reversal

Easy



2124


Check if All A's Appears Before All B's

Easy



2129


Capitalize the Title

Easy



2133


Check if Every Row and Column Contains All Numbers

Easy



2138


Divide a String Into Groups of Size k

Easy



2144


Minimum Cost of Buying Candies With Discount

Easy



2148


Count Elements With Strictly Smaller and Greater Elements

Easy



2


Add Two Numbers

Medium



3


Longest Substring Without Repeating Characters

Medium



5


Longest Palindromic Substring

Medium



6


Zigzag Conversion

Medium



7


Reverse Integer

Medium



8


String to Integer (atoi)

Medium



11


Container With Most Water

Medium



12


Integer to Roman

Medium



15


3Sum

Medium



16


3Sum Closest

Medium



17


Letter Combinations of a Phone Number

Medium



18


4Sum

Medium



19


Remove Nth Node From End of List

Medium



22


Generate Parentheses

Medium



24


Swap Nodes in Pairs

Medium



29


Divide Two Integers

Medium



31


Next Permutation

Medium



33


Search in Rotated Sorted Array

Medium



34


Find First and Last Position of Element in Sorted Array

Medium



36


Valid Sudoku

Medium



38


Count and Say

Medium



39


Combination Sum

Medium



40


Combination Sum II

Medium



43


Multiply Strings

Medium



45


Jump Game II

Medium



46


Permutations

Medium



47


Permutations II

Medium



48


Rotate Image

Medium



49


Group Anagrams

Medium



50


Pow(x, n)

Medium



54


Spiral Matrix

Medium



55


Jump Game

Medium



56


Merge Intervals

Medium



57


Insert Interval

Medium



59


Spiral Matrix II

Medium



61


Rotate List

Medium



62


Unique Paths

Medium



63


Unique Paths II

Medium