Data Structures and Algorithms using Python
Project description
Data Structures and Algorithms
This repository contains my implementations of data structures and algorithms using Python 3. Most of the algorithm questions are taken from LeetCode. This is a work in progress.
Install
You can use this as an API in your code as follows:
$ pip3 install algorithms3
An example of running an algorithm:
#Check if a string containing brackets is valid or not
from algorithms.stack import validate_parantheses
if __name__ == '__main__':
test = validate_parantheses('()[]')
print(test)
If an algorithm is listed in this repository but is not in the pip package, it means that I have not uploaded the latest version. I will be doing that once a week.
Uninstall
If you want to uninstall, simply run:
$pip3 uninstall algorithms3
Tests
I have written basic tests for most of the modules. To run all the tests at once run the following from the base directory of the project:
$python3 -m unittest discover tests
Progress
Data Structures : 13
Algorithms : 482
List of Implementations
-
- Dynamic Array Implementation
- Add To Array Form
- Array Partition
- Assign Cookies
- Best Time To Buy Stock Ii
- Best Time To Buy Stock
- Contains Duplicate One
- Contains Duplicate Range
- Degree Array
- Distribute Candies
- Find All Dissapeared Numbers
- Find All Duplicates
- Find Pivot Index
- First Missing Positive
- Friends Of Ages
- Increasing Triplets
- Intersection Two Arrays Ii
- Is Monotonic
- K Diff Pairs
- Largest Number Twice Of Others
- Longest Continuous Increasing Subsequence
- Max Average Subarray
- Max Consecutive Ones
- Max Product Three Numbers
- Maximize Distance To Nearest Person
- Maximum Subarray
- Merge Intervals
- Merge Sorted Array
- Minimum Moves To Equal Array
- Move Zeroes
- Next Greater Element
- Non Decreasing Array
- Number Plus One
- Partition Array In Three
- Place Flowers
- Positions Large Groups
- Product Of Array Except Self
- Remove Duplicates Two
- Rotate Array
- Set Mismatch
- Shortest Unsorted Subarray
- Smallest Range I
- Sum After Queries
- Summary Ranges
- Third Max Number
- Two Sum Sorted Array
-
- 4Sum Ii
- Arranging Coins
- Binary Search
- Find K Closest
- Find Peak
- Find Right Interval
- First Bad
- Guess Number
- H Index
- Heaters
- Min In Rotated Sorted Array
- Minimum Size Subarray
- Next Greater Letter
- Peak Index Mountain Array
- Search 2D Matrix Ii
- Search 2D Matrix
- Search Insert Position
- Search Range
- Search Rotated Array Ii
- Search Rotated Array
- Sqrt Number
- Valid Perfect Square
-
- Best Sight Seeing Pair
- Capacity To Ship Packages
- Climbing Stairs
- Continuous Subarray Sum
- Delete Operations For Two Strings
- Edit Distance
- Fibonacci
- House Robber
- Integer Replacement
- Jump Game
- Kth Grammar
- Longest Common Subsequence
- Longest Increasing Subsequence
- Max Crossed Lines
- Max Product Subarray
- Maximum Sum Two Non Overlapping Subarray
- Min Cost Climbing Stairs
- Minimum Path Sum
- Nth Ugly Number
- Partition Equal Subset
- Pascal Row
- Pascal
- Pow
- Range Sum Query 2D
- Range Sum Query Mutable
- Range Sum Query
- Super Ugly Number
- Triangle Min Path
- Unique Paths With Obstacle
- Unique Paths
- Zero One Matrix
-
- Graph Implementation
- Bt Right View
- Clone Graph
- Color The Border
- Concatenated Words
- Course Order
- Employee Importance
- Flood Fill
- Flower Planting With No Adjacent
- Friend Circle
- House Robber Three
- Is Bipartate
- Jump Game Ii
- Keys And Rooms
- Longest Increasing Path Matrix
- Make Larger Island
- Max Area Island
- Minesweeper
- Minimum Height Trees
- Network Delay Time
- Number Islands
- Number Of Enclaves
- Pacific Atlantic Water Flow
- Perfect Squares
- Redundant Connection
- Rotton Oranges
- Shortest Bridge
- Surround Region
- Town Judge
- Word Ladder Two
- Word Ladder
- Word Search
-
- Burst Balloons
- Di String Match
- Dota2 Senate
- Fair Candy Swap
- Is Subsequence
- Make Paran Valid
- Max Chunks To Make Sorted Ii
- Max Chunks To Make Sorted
- Maximize Sum Array
- Moving Stones
- Non Overlapping Intervals
- Queue Reconstruction By Height
- Relative Ranks
- Remove Outermost Parantheses
- Reorganize String
- Two City Scheduling
-
- Hashmap Implementation
- Banned Words
- Boomerang Points
- Bulls And Cows
- Deck Of Cards
- Distant Barcodes
- Encode Decode
- Expressive Words
- Find And Replace Pattern
- Find Common Characters
- Four Sum
- Fraction To Decimal
- Group Anagrams
- Hashmap
- Hashset
- Insert Delete Random Duplicates
- Insert Delete Random
- Keyboard Row
- Largest Triangle Area
- Lemonade Change
- Longest Word Dictionary
- Lru Cache
- Magic Dictionary
- Minimum Index Sum Of Two Lists
- N Repeated Elements
- Pairs With Sum
- Powerful Integers
- Repeated Dna Sequences
- Shortest Completing Word
- Shuffle Array
- Sort By Count
- Subdomain Visit Count
- Substring Concat
- Three Sum
- Two Sum
- Uncommon Words
- Valid Sudoku
- Verifying Alien Dictionary
- Word Pattern
- Word Subsets
-
- Singly Linked List Implementation
- Add Two Numbers Ii
- Add Two Numbers
- Delete Duplicates All
- Delete Duplicates
- Delete Node Without Head
- Intersection
- Linked Cycle
- Linked List Cycle Ii
- Linkedlist
- List Palindrome
- Merge K Lists
- Merge Two Lists
- Middle Linked List
- Next Greater Node
- Odd Even Linked List
- Partition List
- Remove Element
- Remove Nth End
- Reorder List
- Reverse K Groups
- Reverse Linkedlist
- Reverse Mn
- Rotate List
- Sort List
- Split List In Parts
- Swap Pairs
-
- Add Binary
- Add Digits
- Basic Calculator I
- Basic Calculator Ii
- Construct Rectangle
- Convert To Base 7
- Convert To Hex
- Convert To Number
- Count Primes
- Count Zeroes Factorial
- Divide Two Numbers
- Game Of Nim
- Hamming Distance
- Happy Numbers
- Integer To English Words
- Intersection Two Arrays
- Largest Triangle Area
- Majority Element
- Min Time Difference
- Minimum Area Rectangle
- Missing Number
- Next Greater Iii
- Next Permutation
- Nth Digit
- Num To Col
- Perfect Number
- Power Of Two
- Reach A Number
- Rectangle Overlap
- Self Dividing Numbers
- Smallest Integer Divisible By K
- Total Time
- Ugly Numbers
- Valid Boomerang
- Valid Number
-
- Brick Wall
- Flip Image
- Game Of Life
- Image Smoother
- Island Perimeter
- Magic Squares In Grid
- Matrix Cells Distance
- Range Addition
- Reshape Matrix
- Robot Bounded Circle
- Rook Captures
- Rotate Image
- Set Matrix Zeros
- Spiral Matrix Generate
- Spiral Matrix Iii
- Spiral Matrix
- Toeplitz Matrix
- Transpose Matrix
- Walking Robot Simulation
-
- Add Binary
- Add Strings
- Backspace Compare
- Buddy Strings
- Camelcase Matching
- Compare Version Numbers
- Complex Number Multiplication
- Count Binary Strings
- Count Say
- Decode String
- Detect Capital
- Find All Anagrams
- Find And Replace
- Find Duplicate Files
- First Unique Character
- Goat Latin
- Int To Roman
- Isomorphic
- Jewels
- Largest Number
- Length Of Last Word
- Licence Key Reformatting
- Long Pressed Name
- Longest Common Prefix
- Longest Palin Substring
- Longest Palindrome
- Longest Substring With K Chars
- Longest Substring Without Repeating
- Longest Uncommon Seq
- Minimum Window String
- Multiply Strings
- Number Of Segments String
- Optimal Division
- Palindrome
- Permutations In String
- Ransom Note
- Remove Comments
- Repeated String Match
- Repeated Substring Pattern
- Reverse Int
- Reverse Only Letters
- Reverse String Ii
- Reverse String Words
- Reverse String
- Reverse Vowels Strings
- Reverse Words Iii
- Robot Origin
- Roman To Int
- Rotated Digits
- Shifting Letters
- Shortest Distance To Character
- String Compression
- String To Integer
- Strstr
- To Lower
- Unique Email
- Unique Morse Code
- Valid Anagram
- Valid Ip
- Valid Palin
- Valid Palindrome Ii
- Valid String After Subs
- Zigzag Conversion
-
- Tree Implementation
- Trie Implementation
- Array Bst
- Average Levels
- Bst To Greater Tree
- Build Tree Postorder
- Construct Pre In
- Count Complete Tree Nodes
- Cousins In Binary Trees
- Diameter Binary Tree
- Find Bottom Left
- Flatten Binary Tree To Linked List
- Inorder
- Invert Tree
- Is Balanced
- Largest Value Level
- Left Similar Trees
- Level Order One
- Level Order Two
- Lowest Common Ancestor
- Max Depth N Ary
- Max Depth
- Max Subtree
- Maximum Diff Between Ancestor And Node
- Maximum Path Sum
- Merge Two Trees
- Min Depth
- Most Frequent Subtree Sum
- N Ary Postorder
- N Ary Preorder
- Nary Level Order
- Nodes At Distance K
- Path Sum All
- Path Sum Iii
- Path Sum
- Populate Next Right Pointer
- Postorder
- Preorder
- Same Tree
- Second Minimum Node
- Serialize Tree
- Subtree Of Another Tree
- Sum Of Left Leaves
- Sum Root To Leaf Paths
- Sum Root To Leafs
- Symmetric
- Tilt Tree
- Tree Paths
- Univalue Tree
- Verify Tree Serialization
- Zigzag Level Order
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file algorithms3-0.1.9.tar.gz
.
File metadata
- Download URL: algorithms3-0.1.9.tar.gz
- Upload date:
- Size: 209.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.9.1 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.5.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4f8f44914bfa49a78cce5d2d58c95299abbf5cfd695b64b460b71f0ab1d5d41c |
|
MD5 | 3ae67bc1a53cc857a313a1d636b79f79 |
|
BLAKE2b-256 | 08d2e4727c8610ddad98affccddf721222fc9b8926dabc6f6f0189646ebd41bc |
File details
Details for the file algorithms3-0.1.9-py3-none-any.whl
.
File metadata
- Download URL: algorithms3-0.1.9-py3-none-any.whl
- Upload date:
- Size: 354.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.9.1 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.5.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f1b309529588f74b473af467551b81942a139772d411322bf416777a54bf7153 |
|
MD5 | 9854b98bf76ddece1311d8b1bb58277f |
|
BLAKE2b-256 | 4368f549b43a2e8012831300693ca4b93a0cfff253f6ff31082f580907d1c3ee |