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 is_valid
if __name__ == '__main__':
test = is_valid('()[]')
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:
$python3 -m unittest discover tests
Progress
Data Structures : 10
Algorithms : 256
List of Implementations
-
- Dynamic Array Implementation
- Assign Cookies
- Best Time To Buy Stock Ii
- Best Time To Buy Stock
- Contains Duplicate One
- Contains Duplicate Range
- Distribute Candies
- Find All Dissapeared Numbers
- First Missing Positive
- Intersection Two Arrays Ii
- K Diff Pairs
- 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
- Place Flowers
- Remove Duplicates Two
- Rotate Array
- Set Mismatch
- Shortest Unsorted Subarray
- Summary Ranges
- Third Max Number
- Two Sum Sorted Array
-
- Climbing Stairs
- Continuous Subarray Sum
- Delete Operations For Two Strings
- Fibonacci
- House Robber
- Kth Grammar
- Longest Common Subsequence
- Longest Increasing Subsequence
- Min Cost Climbing Stairs
- Minimum Path Sum
- Pascal Row
- Pascal
- Pow
- Range Sum Query
- Triangle Min Path
- Unique Paths With Obstacle
- Unique Paths
- Zero One Matrix
-
- Graph Implementation
- Bt Right View
- Clone Graph
- Concatenated Words
- Course Order
- Employee Importance
- Flood Fill
- Friend Circle
- House Robber Three
- Is Bipartate
- Jump Game Ii
- Max Area Island
- Minesweeper
- Number Islands
- Pacific Atlantic Water Flow
- Rotton Oranges
- Surround Region
- Word Ladder Two
- Word Ladder
- Word Search
-
- Singly Linked List Implementation
- 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
- Odd Even Linked List
- Remove Element
- Remove Nth End
- Reorder List
- Reverse K Groups
- Reverse Linkedlist
- Reverse Mn
- Rotate List
- Swap Pairs
-
- Add Binary
- Add Digits
- Basic Calculator I
- Basic Calculator Ii
- Construct Rectangle
- Convert To Number
- Count Primes
- Count Zeroes Factorial
- Divide Two Numbers
- Game Of Nim
- Hamming Distance
- Happy Numbers
- Intersection Two Arrays
- Majority Element
- Min Time Difference
- Missing Number
- Next Permutation
- Nth Digit
- Num To Col
- Perfect Number
- Power Of Two
- Ugly Numbers
- Valid Number
-
- Add Binary
- Add Strings
- Backspace Compare
- Compare Version Numbers
- Count Say
- Decode String
- Detect Capital
- Find All Anagrams
- First Unique Character
- Goat Latin
- Int To Roman
- Isomorphic
- Jewels
- Largest Number
- Length Of Last Word
- Longest Common Prefix
- Longest Palin Substring
- Longest Palindrome
- Longest Substring Without Repeating
- Multiply Strings
- Number Of Segments String
- Palindrome
- Permutations In String
- Ransom Note
- 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
- String Compression
- String To Integer
- Strstr
- To Lower
- Unique Email
- Unique Morse Code
- Valid Anagram
- Valid Ip
- Valid Palin
- Valid Palindrome Ii
- Zigzag Conversion
-
- Tree Implementation
- Trie Implementation
- Array Bst
- Average Levels
- Build Tree Postorder
- Construct Pre In
- Cousins In Binary Trees
- 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
- Max Depth
- Maximum Path Sum
- Merge Two Trees
- Min Depth
- Path Sum All
- Path Sum
- Populate Next Right Pointer
- Postorder
- Preorder
- Same Tree
- Sum Of Left Leaves
- Sum Root To Leaf Paths
- Symmetric
- Tree Paths
- 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
Hashes for algorithms3-0.1.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d91ef93904b8f9c32be625f36ffa1f8ee6ac29394b0ea295e62fb38af9255f4f |
|
MD5 | 1b19883ad5f777c434c5602b254d0f19 |
|
BLAKE2b-256 | a42cb02d84a3a4bee083b9b3e7ab2472459aa8b8db2dd5119da4371b440185dc |