Package: algorithms3
Data Structures and AlgorithmsThis 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.InstallYou can use this as an API in your code as follows:$ pip3 install algorithms3An example of running an algorithm:#Check if a string containing brackets is valid or notfromalgorithms.stackimportvalidate_paranthesesif__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.UninstallIf you want to uninstall, simply run:$pip3 uninstall algorithms3TestsI 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 testsProgressData Structures: 13Algorithms: 482List of ImplementationsArraysDynamic Array ImplementationAdd To Array FormArray PartitionAssign CookiesBest Time To Buy Stock IiBest Time To Buy StockContains Duplicate OneContains Duplicate RangeDegree ArrayDistribute CandiesFind All Dissapeared NumbersFind All DuplicatesFind Pivot IndexFirst Missing PositiveFriends Of AgesIncreasing TripletsIntersection Two Arrays IiIs MonotonicK Diff PairsLargest Number Twice Of OthersLongest Continuous Increasing SubsequenceMax Average SubarrayMax Consecutive OnesMax Product Three NumbersMaximize Distance To Nearest PersonMaximum SubarrayMerge IntervalsMerge Sorted ArrayMinimum Moves To Equal ArrayMove ZeroesNext Greater ElementNon Decreasing ArrayNumber Plus OnePartition Array In ThreePlace FlowersPositions Large GroupsProduct Of Array Except SelfRemove Duplicates TwoRotate ArraySet MismatchShortest Unsorted SubarraySmallest Range ISum After QueriesSummary RangesThird Max NumberTwo Sum Sorted ArrayBacktrackingBinary WatchCombinations Sum ThreeCombinations Sum TwoCombinations SumCombinationsGenerate ParanthesisLetter Case PermutationsLetter CombinationsMatchsticks To SquareN Queens IiN QueensPermutation SequencePermutations OnePermutations TwoSubsets DuplicatesSubsetsValid TimeBashTenth LineValid Phone NumberBinarysearch4Sum IiArranging CoinsBinary SearchFind K ClosestFind PeakFind Right IntervalFirst BadGuess NumberH IndexHeatersMin In Rotated Sorted ArrayMinimum Size SubarrayNext Greater LetterPeak Index Mountain ArraySearch 2D Matrix IiSearch 2D MatrixSearch Insert PositionSearch RangeSearch Rotated Array IiSearch Rotated ArraySqrt NumberValid Perfect SquareBitsBinary GapComplement Base 10 IntegerCount 1 BitsCount Set Bits PrimeIs One Bit CharacterNumber With Alternating BitsPrefix Divisible 5Reverse BitsSingle NumberSum Two NumbersBinary Search TreeBst ImplementationBst IteratorBst To Greater Sum TreeDelete NodeFind Mode BstIncreasing Order Search TreeKth Smallest ElementList To BstLowest Common Ancestor BstMin Distance BstMinimum Diff BstRange Sum BstRecover BstSearch BstTwo Sum BstValidate BstDynamic ProgrammingBest Sight Seeing PairCapacity To Ship PackagesClimbing StairsContinuous Subarray SumDelete Operations For Two StringsEdit DistanceFibonacciHouse RobberInteger ReplacementJump GameKth GrammarLongest Common SubsequenceLongest Increasing SubsequenceMax Crossed LinesMax Product SubarrayMaximum Sum Two Non Overlapping SubarrayMin Cost Climbing StairsMinimum Path SumNth Ugly NumberPartition Equal SubsetPascal RowPascalPowRange Sum Query 2DRange Sum Query MutableRange Sum QuerySuper Ugly NumberTriangle Min PathUnique Paths With ObstacleUnique PathsZero One MatrixGraphsGraph ImplementationBt Right ViewClone GraphColor The BorderConcatenated WordsCourse OrderEmployee ImportanceFlood FillFlower Planting With No AdjacentFriend CircleHouse Robber ThreeIs BipartateJump Game IiKeys And RoomsLongest Increasing Path MatrixMake Larger IslandMax Area IslandMinesweeperMinimum Height TreesNetwork Delay TimeNumber IslandsNumber Of EnclavesPacific Atlantic Water FlowPerfect SquaresRedundant ConnectionRotton OrangesShortest BridgeSurround RegionTown JudgeWord Ladder TwoWord LadderWord SearchGreedyBurst BalloonsDi String MatchDota2 SenateFair Candy SwapIs SubsequenceMake Paran ValidMax Chunks To Make Sorted IiMax Chunks To Make SortedMaximize Sum ArrayMoving StonesNon Overlapping IntervalsQueue Reconstruction By HeightRelative RanksRemove Outermost ParanthesesReorganize StringTwo City SchedulingHash TablesHashmap ImplementationBanned WordsBoomerang PointsBulls And CowsDeck Of CardsDistant BarcodesEncode DecodeExpressive WordsFind And Replace PatternFind Common CharactersFour SumFraction To DecimalGroup AnagramsHashmapHashsetInsert Delete Random DuplicatesInsert Delete RandomKeyboard RowLargest Triangle AreaLemonade ChangeLongest Word DictionaryLru CacheMagic DictionaryMinimum Index Sum Of Two ListsN Repeated ElementsPairs With SumPowerful IntegersRepeated Dna SequencesShortest Completing WordShuffle ArraySort By CountSubdomain Visit CountSubstring ConcatThree SumTwo SumUncommon WordsValid SudokuVerifying Alien DictionaryWord PatternWord SubsetsHeapsHeap ImplementationPriority Queue ImplementationCheck Valid TriangleDesign TwitterK Most FrequentK Pairs With Smallest SumsKth Largest In StreamKth LargestKth Smallest In Sorted MatrixLast Stone WeightMedian Of StreamTop K Frequent WordsLinked ListSingly Linked List ImplementationAdd Two Numbers IiAdd Two NumbersDelete Duplicates AllDelete DuplicatesDelete Node Without HeadIntersectionLinked CycleLinked List Cycle IiLinkedlistList PalindromeMerge K ListsMerge Two ListsMiddle Linked ListNext Greater NodeOdd Even Linked ListPartition ListRemove ElementRemove Nth EndReorder ListReverse K GroupsReverse LinkedlistReverse MnRotate ListSort ListSplit List In PartsSwap PairsMathAdd BinaryAdd DigitsBasic Calculator IBasic Calculator IiConstruct RectangleConvert To Base 7Convert To HexConvert To NumberCount PrimesCount Zeroes FactorialDivide Two NumbersGame Of NimHamming DistanceHappy NumbersInteger To English WordsIntersection Two ArraysLargest Triangle AreaMajority ElementMin Time DifferenceMinimum Area RectangleMissing NumberNext Greater IiiNext PermutationNth DigitNum To ColPerfect NumberPower Of TwoReach A NumberRectangle OverlapSelf Dividing NumbersSmallest Integer Divisible By KTotal TimeUgly NumbersValid BoomerangValid NumberMatrixBrick WallFlip ImageGame Of LifeImage SmootherIsland PerimeterMagic Squares In GridMatrix Cells DistanceRange AdditionReshape MatrixRobot Bounded CircleRook CapturesRotate ImageSet Matrix ZerosSpiral Matrix GenerateSpiral Matrix IiiSpiral MatrixToeplitz MatrixTranspose MatrixWalking Robot SimulationMysqlBig Countries.Classes More Than 5.Combine Two Tables.Customers Who Never Order.Delete Duplicate Emails.Duplicate Emails.Employee Earning More Than Managers.Not Boring Movies.Rising Temperature.Second Highest Salary.Swap Salary.QueuesCircular Deque ImplementationCircular Queue ImplementationQueue ImplementationGas StationMax Sliding WindowQueue Using StacksRotate StringStack Using QueuesSortBubble SortDelete Columns To Make SortedHeight CheckerInsertion SortLongest Harmonious SequenceMax GapMerge SortMost Profit WorkersQuick SortReorder LogsSelection SortSort Array Parity IiSort By ParitySort Three ColorsStackBaseball GameDuplicate RemovalEvaluate Reverse Polish NotationExclusive Fuction TimeMin StackNext Greater Element IiOne Three Two PatternRemove K DigitsSimplify PathValid ParanValidate Stack SequenceStringsAdd BinaryAdd StringsBackspace CompareBuddy StringsCamelcase MatchingCompare Version NumbersComplex Number MultiplicationCount Binary StringsCount SayDecode StringDetect CapitalFind All AnagramsFind And ReplaceFind Duplicate FilesFirst Unique CharacterGoat LatinInt To RomanIsomorphicJewelsLargest NumberLength Of Last WordLicence Key ReformattingLong Pressed NameLongest Common PrefixLongest Palin SubstringLongest PalindromeLongest Substring With K CharsLongest Substring Without RepeatingLongest Uncommon SeqMinimum Window StringMultiply StringsNumber Of Segments StringOptimal DivisionPalindromePermutations In StringRansom NoteRemove CommentsRepeated String MatchRepeated Substring PatternReverse IntReverse Only LettersReverse String IiReverse String WordsReverse StringReverse Vowels StringsReverse Words IiiRobot OriginRoman To IntRotated DigitsShifting LettersShortest Distance To CharacterString CompressionString To IntegerStrstrTo LowerUnique EmailUnique Morse CodeValid AnagramValid IpValid PalinValid Palindrome IiValid String After SubsZigzag ConversionTreesTree ImplementationTrie ImplementationArray BstAverage LevelsBst To Greater TreeBuild Tree PostorderConstruct Pre InCount Complete Tree NodesCousins In Binary TreesDiameter Binary TreeFind Bottom LeftFlatten Binary Tree To Linked ListInorderInvert TreeIs BalancedLargest Value LevelLeft Similar TreesLevel Order OneLevel Order TwoLowest Common AncestorMax Depth N AryMax DepthMax SubtreeMaximum Diff Between Ancestor And NodeMaximum Path SumMerge Two TreesMin DepthMost Frequent Subtree SumN Ary PostorderN Ary PreorderNary Level OrderNodes At Distance KPath Sum AllPath Sum IiiPath SumPopulate Next Right PointerPostorderPreorderSame TreeSecond Minimum NodeSerialize TreeSubtree Of Another TreeSum Of Left LeavesSum Root To Leaf PathsSum Root To LeafsSymmetricTilt TreeTree PathsUnivalue TreeVerify Tree SerializationZigzag Level OrderTrieTrie ImplementationLongest Word DictionaryReplace WordsWord Search IiTwo PointersContainer With Most WaterFind Duplicate NumberLongest Repeating Character ReplacementLongest Word In DictionaryRemove DuplicatesRemove ElementSquares Of Sorted ArrayThree Sum Closest