Skip to content

Some algorithmics work done in Python 3 and misc. code

Notifications You must be signed in to change notification settings

StBogdan/PythonWork

Repository files navigation

Python Work

  • Programming exercises repository for algorithmic problems, done in Python 3
  • Code quality varies, there's stuff here before I knew I could auto-format code

Contents

CodeForces

Nr. Title Solution Difficulty Time Space Notes
1285A Mezo Playing Zoma Python A O(n) O(1)
1287A Angry Students Python A O(n) O(1)
1287B Hyperset Python B O(n^2 * k) O(n*k)

HackerRank

Problems related to the Python tag

Leetcode

Nr. Title Solution Difficulty Time Space Notes
1 Two Sum Python Easy O(n) O(n)
2 Add Two Numbers Python Medium O(n) O(n)
3 Longest Substring Without Repeating Characters Python Medium O(n) O(n)
5 Longest Palindromic Substring Python Medium O(n^2) O(n)
7 Reverse Integer Python Easy O(log(n)) O(1)
15 3sum Python Medium O(n^2) O(n)
16 3Sum Closest Python Medium O(n^2) O(n)
17 Letter Combinations of a Phone Number Python Medium O(4^n) O(4^n)
19 Remove Nth Node From End of List Python Medium O(n) O(1)
21 Merge Two Sorted Lists Python Easy O(n) O(1)
22 Generate Parentheses Python Medium O(4^n / sqrt(n)) O(4^n / sqrt(n))
31 Next Permutation Python Medium O(n) O(1)
33 Search in Rotated Sorted Array Python Medium O(log(n)) O(1)
43 Multiply Strings Python Medium O(n*m) O(n + m)
56 Merge Intervals Python Medium O(n*log(n)) O(n) Result array
64 Minimum Path Sum Python Medium O(n*m) O(n*m)
98 Validate Binary Search Tree Python Medium O(n) O(depth)
116 Populating Next Right Pointers in Each Node Python Medium O(n) O(log(depth))
124 Binary Tree Maximum Path Sum Python Hard O(n) O(d) where d = tree depth (worst case also n)
152 Maximum Product Subarray Python Medium O(n) O(1)
159 Longest Substring with At Most Two Distinct Characters Python Medium O(n) O(1)
188 Best Time to Buy and Sell Stock IV Python Hard O(n*k) O(n*k)
198 House Robber Python Medium O(n) O(1)
200 Number of Islands Python Medium O(n*m) O(n*m)
213 House Robber II Python Medium O(n) O(1)
246 Strobogrammatic Number Python Easy O(n) O(1)
247 Strobogrammatic Number II Python Medium O(5^n) O(5^n)
300 Longest Increasing Subsequence Python Medium O(n*log(n)) O(n)
322 Coin Change Python Medium O(m * n) O(m)
410 Split Array Largest Sum Python Hard O(n^2 * m) O(n * m)
418 Sentence Screen Fitting Python Medium O(~r * c ) O(w)
460 LFU Cache Python Hard O(1) for getting and setting O(n)-ish
492 License Key Formatting Python Easy O(n) O(n)
543 Diameter of Binary Tree Python Easy O(n) O(d)
547 Number of Provinces Python Medium O(n^2) O(n)
560 Subarray Sum Equals K Python Medium O(n) O(n)
593 Valid Square Python Medium O(1) O(1)
616 Add Bold Tag in String Python Mediun O(w + n*m) O(w + n)
647 Palindromic Substrings Python Medium O(n^2) O(1)
652 Find Duplicate Subtrees Python Medium O(n^2) O(n^2)
731 My Calendar II Python Medium O(n^2) O(n)
777 Swap Adjacent in LR String Python Medium O(n) O(n)
792 Number of Matching Subsequences Python Medium O(n * m) O(m)
829 Consecutive Numbers Sum Python Hard O(N^(1/2)) O(1)
833 Find And Replace in String Python Medium O(n) O(n)
844 Backspace String Compare Python Easy O(n) O(n)
852 Peak Index in a Mountain Array Python Easy O(log(n)) O(1)
876 Middle of the Linked List Python Easy O(n) O(1)
904 Fruit Into Baskets Python Medium O(n) O(1)
929 Unique Email Addresses Python Easy O(n) O(n)
935 Knight Dialer Python Medium O(n) O(1)
937 Reorder Data in Log Files Python Easy O(n*log(n)) O(n)
939 Minimum Area Rectangle Python Medium O(n^2) O(n)
987 Vertical Order Traversal of a Binary Tree Python Hard O(n * log(n)) O(n)
1029 Two City Scheduling Python Medium O(n * log(n)) O(n)
1041 Robot Bounded In Circle Python Medium O(n) O(1)
1074 Number of Submatrices That Sum to Target Python Hard O(n^2*m) O(n*m)
1110 Delete Nodes And Return Forest Python Medium O(n) O(n)
1136 Parallel Courses Python Medium O(V + E) O(V + E)
1167 Minimum Cost to Connect Sticks Python Medium O(n*log(n)) O(n)
1396 Design Underground System Python Medium O(1) O(n)
1465 Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts Python Medium O(n*log(n)) O(n)
1472 Design Browser History Python Medium ~O(1) O(n)
1499 Max Value of Equation Python Hard O(n*log(n)) O(n)
1525 Number of Good Ways to Split a String Python Medium O(n) O(n)
1548 The Most Similar Path in a Graph Python Hard O(n*m*E) O(n*m)
1648 Sell Diminishing-Valued Colored Balls Python Medium O(n* log(n)) O(n)
1725 Number Of Rectangles That Can Form The Largest Square Python Easy O(n) O(1)
1726 Tuple with Same Product Python Medium O(n^2) O(n^2)
1727 Largest Submatrix With Rearrangements Python Medium O(nmlog(m)) O(n*m)
1776 Car Fleet II Python Hard O(n) O(n)
1891 Cutting Ribbons Python Medium O(n*log(max(n))) O(1)

Links

Algorithms

Problem lists

System Design

This, but for: