Welcome! This repository is my personal collection of Python code, focusing on algorithms, data structures, Object-Oriented Programming (OOP), Low-Level Design (LLD), and solutions to various coding challenges (primarily LeetCode). It serves as a space for learning, practice, and demonstrating problem-solving approaches.
Navigation: Use the Table of Contents below or expand the collapsible sections to explore different categories.
- Low-Level Design (LLD)
- Maths
- Patterns
- Sorting
- Array
- Binary Search
- Graph
- Hashing
- Set
- String
- Tree
- Other Concepts
- How to Use
- Contributing
Click the <summary>
tags to expand/collapse the detailed file lists for each category.
Low-Level Design (LLD) π¨ (6 items)
Program Name | Location | Status | Notes |
---|---|---|---|
Design Stack Overflow (Conceptual) | LLD/Design Stackoverflow/ | Done | Basic structure files |
Basic Class Example | LLD/Oops/class.py | Done | |
Payment Interface Example (Interface/ABC) | LLD/Oops/interface_and_abc/payments_example/ | Done | Demonstrates interface concept |
Vehicle Interface Example (Interface/ABC) | LLD/Oops/interface_and_abc/vehicles_example/ | Done | Demonstrates interface concept |
Tic Tac Toe (Requirement Gathering Conceptual) | LLD/Tic Tac Toe/Requirement Gathering | Done | Text description |
Tic Tac Toe Implementation | LLD/Tic Tac Toe/tic_tac_toe.py | Done |
Maths π (47 items)
Program Name | Location | Status | Notes (LeetCode #) |
---|---|---|---|
Is Palindrome (Integer Overflow Avoidance) | is_a_no_palindrome_bruteforce_to_avoid_integer_overflow.py | Done | 9 - Variation |
Is Palindrome (Compare MSB/LSB) | is_a_no_palindrome_by_comparing_lsb_and_msb_and_chopping_them_both.py | Done | 9 - Variation |
Is Palindrome (Optimized Integer) | is_a_no_palindrome_optimized.py | Done | 9 |
Is Palindrome (Integer Overflow Prone) | is_a_no_palindrome_prone_to_integer_overflow.py | Done | 9 - Variation |
Is Palindrome (String Reverse) | is_a_no_palindrome_using_string_and_reversing_complete_string.py | Done | 9 - Variation |
Is Palindrome (String Two Pointer) | is_a_no_palindrome_using_string_and_using_two_pointer.py | Done | 9 - Variation |
Arithmetic Subarrays (Bruteforce) | arithmetic_subarrays_1630_bruteforce.py | Done | 1630 |
Arithmetic Subarrays (Optimized) | arithmetic_subarrays_1630_optimized_without_sorting.py | Done | 1630 |
Avg Values of Even Nos Divisible by Three | avg_values_of_even_nos_that_are_divisible_by_three_2455.py | Done | 2455 |
Base 7 | base_7_504.py | Done | 504 |
Check If No is Sum of Power of Three | check_if_no_is_sum_of_power_of_three_1780.py | Done | 1780 |
Check If the No is Fascinating | check_if_the_no_is_fascinating_2729.py | Done | 2729 |
Closest Prime Numbers in Range (TLE Likely) | closest_prime_no_in_ranges_2523.py | Done | 2523 |
Closest Prime Numbers in Range (Optimized Sieve) | closest_prime_no_in_ranges_2523_n*sqrt(n).py | Done | 2523 |
Color of Chessboard Square | color_of_chessboard_1812.py | Done | 1812 |
Complex Number Multiplication | complex_no_multiplication_537.py | Done | 537 |
Count Digits | count_no_of_digits.py | Done | |
Count Digits (Optimized Log) | count_no_of_digits_optimized.py | Done | |
Count Primes (Bruteforce) | count_primes_204_bruteforce_n_*_sqrt(n).py | Done | 204 |
Count Primes (Sieve of Eratosthenes) | count_primes_204_sieve_of_eratosthenes..py | Done | 204 |
Count Symmetrical Integers | count_symmetrical_integers_2843.py | Done | 2843 |
Difference Between Element Sum and Digit Sum | difference_betwen_element_sum_and_digit_sum_2535.py | Done | 2535 |
Fibonacci Number | fibonacii_number_509.py | Done | 509 |
Find GCD of Array | find_gcd_of_array_1979.py | Done | 1979 |
Find if Digits Can be Won (Typo?) | find_if_digits_can_be_won_3232.py | Done | (Typo? Needs check) |
Find the Difference (XOR) | find_the_difference_using_xor_389.py | Done | 389 |
Find the Pivot Integer | find_the_pivot_integer_2485.py | Done | 2485 |
GCD Implementation | gcd.py | Done | |
Harshad Number | harshad_no_3099.py | Done | 3099 |
Is Armstrong Number | is_armstrong_no.py | Done | |
Is Prime (Optimized) | is_prime_optimized.py | Done | |
Is Ugly | is_ugly_263.py | Done | 263 |
Max Sum of Pair with Equal Digit Sum (Bruteforce) | max_sum_of_a_pair_with_equal_sum_of_digits_2342_bruteforce_quadratic.py | Done | 2342 |
Max Sum of Pair with Equal Digit Sum (Hashing) | max_sum_of_a_pair_with_equal_sum_of_digits_2342_linear_time_hashing.py | Done | 2342 |
Number After Double Reversal (Modulo) | no_after_double_reversal_2119_modulous.py | Done | 2119 |
Number of 1 Bits (Hamming Weight) | no_of_1_bits_191_logn.py | Done | 191 |
Number of Common Factors | no_of_common_factors_2427.py | Done | 2427 |
Number of Steps to Reduce a Number to Zero | no_of_steps_to_reduce_a_no_to_zero.py | Done | 1342 |
Print All Divisors | print_all_divisors.py | Done | |
Reverse a Number | reverse_a_no.py | Done | 7 |
Set Mismatch (Using Math) | set_mismatch_645_using_math.py | Done | 645 |
Sieve of Eratosthenes Implementation | sieve_of_eratosthenes.py | Done | |
Single Element in a Sorted Array (Bruteforce) | singleNonDuplicate540.py | Done | 540 |
Single Element in a Sorted Array (Binary Search) | singleNonDuplicate540_binary_search.py | Done | 540 |
Square Root (Bruteforce) | square_root_of_a_no_69_bruteforce_sqrt_time_complexity.py | Done | 69 |
Subtract Product and Sum of Digits | subtact_prod_and_sum_of_digits_of_a_no_1281.py | Done | 1281 |
Sum Multiples | sum_multiples_2652.py | Done | 2652 |
Sum Multiples (Optimized O(1)) | sum_multiples_2652_optimized.py | Done | 2652 |
The Kth Factor of N | the_kth_factor_of_n_1492.py | Done | 1492 |
Three Divisors (Linear Time) | three_divisors_linear_time_1952.py | Done | 1952 |
Three Divisors (Optimized Prime Check) | three_divisors_optimized_using_prime_no_1952.py | Done | 1952 |
Water Bottles | water_bodies_1518.py | Done | 1518 |
XOR Operation in an Array | xor_operation_in_array_1486.py | Done | 1486 |
Patterns πΌοΈ (11 items)
Program Name | Location | Status |
---|---|---|
Decreasing Stars Pyramid | decreasing_stars_top_to_bottom_pyramid.py | Done |
Diamond Pattern | diamond.py | Done |
Half Diamond Pattern | halfdiamond.py | Done |
Numbers Pyramid | numbers_top_to_bottom_pyramid.py | Done |
Numbers Pyramid (Alternative) | numbers_top_to_bottom_pyramid_alternative_solution.py | Done |
Numbers Pyramid (Row No Repeat) | numbers_top_to_bottom_pyramid_row_no_repeat.py | Done |
Stars Square Pattern | stars_square_pattern.py | Done |
Stars Pyramid | stars_top_to_bottom_pyramid.py | Done |
Christmas Tree | xmastree.py | Done |
Inverted Christmas Tree | xmastree_inverted.py | Done |
Sorting β (28 items)
Array π’ (60 items)
Binary Search π (23 items)
Graph πΈοΈ (3 items)
Program Name | Location | Status | Notes (LC #) |
---|---|---|---|
Find Center of Star Graph (Optim.) | find_center_of_star_graph_optimized_1791.py | Done | 1791 |
Find Center of Star Graph (Hash) | find_center_of_star_graph_using_hashing1791.py | Done | 1791 |
Number of Islands | no_of_islands_200.py | Done | 200 - DFS/BFS |
Hashing π (25 items)
Program Name | Location | Status | Notes (LC #) |
---|---|---|---|
Common Elements Between Two Arrays | common_elements_between_two_arrays_2956.py | Done | 2956 |
Contains Duplicate | contains_dupilcate_217.py | Done | 217 |
Count Frequency | count_frequency.php.py | Done | (Filename typo) |
Determine if String Halves Are Alike | determine_if_string_halves_are_alike_1704.py | Done | 1704 |
Divide Array Into Equal Pairs | divide_array_into_equal_parts_2206.py | Done | 2206 |
Find the Difference (Hashing) | find_the_difference_389.py | Done | 389 |
Find Words That Can Be Formed by Characters | find_words_219.py | Done | 1160 |
Basic Hashing Function Example | hashing_function.py | Done | |
HashMap Chaining Example | hashmap_chaining_to_avoid_collision.py | Done | |
HashMap Class Example | hashmap_class.py | Done | |
Intersection of Two Arrays II | intersection_of_two_arrays_II_350.py | Done | 350 |
Isomorphic Strings | isomorphic_strings_205.py | Done | 205 |
Jewels and Stones (Dict) | jewels_and_stones_dictionary_way_771.py | Done | 771 |
Jewels and Stones (Loops) | jewels_and_stones_long_way_771.py | Done | 771 |
Jewels and Stones (Set) | jewels_and_stones_using_set_771.py | Done | 771 |
Kth Distinct String in an Array | kth_distinct_string_in_an_array_2053.py | Done | 2053 |
Majority Element | majority_element_169.py | Done | 169 |
Merge Two 2D Arrays (Hashing) | merge_two_2D_arrays_by_summing_values_2570_linear_space_hashing.py | Done | 2570 |
Min Pushes to Type Word II | min_no_of_pushes_to_type_word_II_3016_hashing.py | Done | 3016 |
Minimum Steps to Make Two Strings Anagram | minimum_no_of_steps_to_make_two_strings_anagram_1347.py | Done | 1347 |
Missing Number | missing_number_268.py | Done | 268 |
Most Frequent/Least Frequent Element | most_frequent_least_frequent_element.py | Done | (Custom) |
Ransom Note | ransom_note_383.py | Done | 383 |
Single Number | single_number_136.py | Done | 136 - XOR better |
Sum of Unique Elements | sum_of_unique_elements_1748.py | Done | 1748 |
Two Sum | two_sum_1.py | Done | 1 |
Valid Anagram | valid_anagram_242.py | Done | 242 |
Word Pattern | word_pattern_290.py | Done | 290 |
Set π§ (2 items)
Program Name | Location | Status | Notes (LC #) |
---|---|---|---|
Greatest English Letter (Set) | greatest_english_letter_in_upper_case_and_lower_case_2309_optimized_set.py | Done | 2309 |
Unique Email Addresses | unique_email_address_929.py | Done | 929 |
String π (49 items)
Tree π³ (4 items)
Program Name | Location | Status | Notes (LC #) |
---|---|---|---|
Binary Tree Inorder Traversal | binary_tree_inorder_traversal_94.py | Done | 94 |
Binary Tree Level Order Traversal | binary_tree_level_order_traversal_102.py | Done | 102 |
Binary Tree Postorder Traversal | binary_tree_postorder_traversal_94.py | Done | 145 |
Binary Tree Preorder Traversal | binary_tree_preorder_traversal_144.py | Done | 144 |
Other Concepts π‘ (10 items)
Program Name | Location | Status | Notes |
---|---|---|---|
Basic Loops Example | Loops/loops.py | Done | |
Factorial | recursion/factorial.py | Done | |
Fibonacci | recursion/fibonacci.py | Done | |
Max in Array (Recursion) | recursion/max_in_an_array.py | Done | |
Min in Array (Recursion) | recursion/min_in_an_array.py | Done | |
Print Reverse String (Recursion) | recursion/printReverseString.py | Done | |
Print Array (Recursion) | recursion/print_elements_of_array.py | Done | |
Print Array Reverse (Recursion) | recursion/print_elements_of_array_reverse_order.py | Done | |
Python Profiling - Bottleneck | [pythonprofiling/bottleneck_checking.py](Python Concepts/Python Profiling/bottleneck_checking.py) | Done | Example |
Python Profiling - Frequencies | [pythonprofiling/call_frequencies.py](Python Concepts/Python Profiling/call_frequencies.py) | Done | Example |
Python Profiling - Time Check | [pythonprofiling/optimization_time_check.py](Python Concepts/Python Profiling/optimization_time_check.py) | Done | Example |
- Clone the repository:
git clone <your-repo-url>
- Navigate: Browse the directories based on the category you're interested in (e.g.,
cd array
). - Run: Execute the Python files directly using
python <filename>.py
. Check individual files for any specific usage notes or required inputs.
This repository is primarily for my personal learning and practice. However, constructive feedback, suggestions for optimizations, or bug reports are welcome! Please feel free to open an issue.