Skip to content

LuciaHarcekova/Algorithms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Algorithms

Complete resources to practice problems solving and prepare for coding interviews. This repo shows my solutions in C# and Python for real interview questions taken from different sites (the origin link to the question is always in the description). Currently, we have a few completed solutions focused on Array, String, Linked List, Stack, Queue, and other data structures.

C C# C++ Python Java JavaScript TypeScript Swift

Please feel free to reference and ⭐ to support this repo, thank you!

Open Source? Yes!

List of Algorithms

Array

Title Solution Difficulty Time Space
Minimum Average Difference Medium O(n) O(1)
Rotate Image Medium O(n^2) O(1)
Zero Matrix C# Python Java Easy O(n*m) O(n+m)
Minimum Falling Path Sum C# Python Java Easy O(n^2) O(1)
Intersection of Two Arrays C# Python Java Easy O(n+m) O(n+m)
House Robber C# Python Java Medium O(n) O(1)
Longest Subsequence With Limited Sum C# Python Java Easy O(n*m) O(m)
Jump Game C# Python Java Medium O(n) O(1)
Maximum Bags With Full Capacity of Rocks C# Python Java Medium O(n) O(1)
Unique Paths III C# Python Java Hard O(nxm) O(1)
Delete Columns to Make Sorted C# Python Java Hard O(nxm) O(1)
Minimum Number of Arrows to Burst Balloons C# Python Java Medium O(n) O(1)
Maximum Ice Cream Bars C# Python Java Medium O(nlogn) O(1)
Gas Station C# Python Java Medium O(n) O(1)
Insert Interval C# C++ Python Java Medium O(n) O(n)
Maximum Sum Circular Subarray C# C++ Python Java JavaScript Medium O(n) O(n)
Subarray Sums Divisible by K C# C++ Python Java Medium O(n) O(k)
Non-decreasing Subsequences Java Medium O(n) O(1)
Search Insert Position C C# C++ Python Java JavaScript TypeScript Swift Easy O(log n) O(1)
Single Element in a Sorted Array C# C++ Python Java Medium O(log n) O(1)
Capacity To Ship Packages Within D Days C# C++ Python Java Medium O(n) O(1)
Check if There is a Valid Partition For The Array C# C++ Python Java Medium O(n) O(n)
Kth Largest Element in an Array C# C++ Python Java Medium O(nlogk) O(k)
01 Matrix C# Python Java Medium O(n*m) O(1)
Pascal's Triangle C# Python Java Medium O(n) O(n)
3Sum C# Python Java Medium O(n^2) O(1)
Container With Most Water C# Python Java Medium O(n) O(1)
Search in Rotated Sorted Array C# Python Java Medium O(log n) O(1)
Count Subarrays Where Max Element Appears at Least K Times C# Python Java Medium O(n) O(n)
Subarrays with K Different Integers C# Python Java Hard O(n) O(n)
Count Subarrays With Fixed Bounds C# Python Java Hard O(n) O(1)
Word Search C# Python Java Medium O(mn4l^) O(1)

String

Title Solution Difficulty Time Space
Determine if String Halves Are Alike Easy O(n) O(1)
Determine if Two Strings Are Close Medium O(n) O(n)
Sort Characters By Frequency Medium O(n) O(n)
Is Unique C# Python Java Easy O(n) O(1)
Check Permutation C# Python Java Easy O(n) O(1)
URLify C# Python Java Easy O(n) O(1)
Palindrome Permutation C# Python Java Medium O(n) O(1)
One Way C# Python Java Medium O(n) O(n)
String Compression C# Python Java Medium O(n) O(1)
Word Pattern C# Python Java Easy O(n) O(n)
Detect Capital C# Python Java Easy O(n) O(1)
Lexicographically Smallest Equivalent String Python Java Medium O(n) O(n)
Flip String to Monotone Increasing C# C++ Python Java Swift Medium O(n) O(1)
Permutation in String C# C++ Python Java JavaScript TypeScript Medium O(l_1+(l_2-l_1)) O(1)
Find the Index of the First Occurrence in a String C# C++ Python Java Easy O(n) O(1)
Custom Sort String C# Python Java Easy O(n) O(n)
String to Integer (atoi) C# Python Java Medium O(n) O(1)
Zigzag Conversion C# Python Java Medium O(n) O(n)
Find the Duplicate Number C# Python Java Medium O(n log_2 n) O(1)
Length of Last Word C# Python Java Easy O(n) O(1)
Count and Say C# Python Java Medium O(n^2) O(n)
Make The String Great C# Python Java Easy O(n) O(1)

Linked List

Title Solution Difficulty Time Space
Middle of the Linked List Easy O(n) O(1)
Odd Even Linked List Python Java Medium O(n) O(1)
Intersection of Two Linked Lists Python Java Easy O(n) O(1)
Partition List C++ Python Java Medium O(n) O(1)
Swap Nodes in Pairs C# C++ Python Java Medium O(n) O(1)

Hash Table

Title Solution Difficulty Time Space
Letter Combinations of a Phone Number Python Java Medium O(n) O(1)
Minimum Rounds to Complete All Tasks Python Java Medium O(n) O(n)
Max Points on a Line Python Java Hard O(n^2) O(n)
Naming a Company Java Hard O(n) O(n)
Isomorphic Strings C# Python Java Easy O(n) O(n)

Bit manipulation

Title Solution Difficulty Time Space
Find the Difference Python Java Easy O(n+m) O(1)
Reverse Bits C++ Python Java Easy O(1) O(1)
Add Binary C# Python Java Easy O(1) O(1)

Queue

Title Solution Difficulty Time Space
IPO C# Java Hard O(n*log(n)) O(n)
Minimize Deviation in Array C# C++ Python Java Hard O(nlog(n)) O(n)
Total Cost to Hire K Workers C# Medium O((k+2n)*log(2n)) O(log 2n)
Shortest Path to Get All Keys C# Hard O(m*n) O(m*n)
Sliding Window Maximum C++ Python Java Hard O(n) O(k)

Stack

Title Solution Difficulty Time Space
Evaluate Reverse Polish Notation C# Python Java Medium O(n) O(n)

Sorting

Title Solution Difficulty Time Space
Majority Element C# Python Java Medium O(n/2) O(1)
Sort Colors C# Python Java Medium O(n) O(1)

Tree

Title Solution Difficulty Time Space
Symmetric Tree Java Easy O(log n) O(1)
Range Sum of BST C# Python Java Easy O(n) O(1)
Leaf-Similar Trees C# Python Java Easy O(n) O(n)
Binary Tree Preorder Traversal C# Python Java JavaScript TypeScript Swift Easy O(n) O(n)
Max Difference Between Node and Ancestor C# Python Java Medium O(n) O(1)
Max Product of Splitted Binary Tree C# Python Java Medium O(n) O(n)
Binary Tree Maximum Path Sum C# Python Java Hard O(n) O(1)
Find if Path Exists in Graph C# Python Java Easy O(V+E) O(V)
All Paths From Source to Target C# Python Java Medium O(n) O(n)
Same Tree C# Python Java JavaScript Easy O(nlogn) O(1)
Minimum Time to Collect All Apples in a Tree C# Python Java Medium O(n) O(n)
Number of Nodes in the Sub-Tree With the Same Label C# Python Java Swift Medium O(n) O(n)
Longest Path With Different Adjacent Characters C# Python Java Hard O(n) O(n)
Number of Good Paths Python Java Hard O(nlogn) O(n)
Minimum Fuel Cost to Report to the Capital C# C++ Python Java Medium O(n) O(n)
Construct Quad Tree C# Python Java Swift Medium O(N^2) O(N^2)
Minimum Absolute Difference in BST C# Easy O(N) O(1)
Maximum Level Sum of a Binary Tree C# Python Java Medium O(N) O(N)
Path Sum C# Python Java Easy O(log N) O(1)
Balanced Binary Tree C# Python Java Easy O(log N) O(1)

Graph

Title Solution Difficulty Time Space
Find if Path Exists in Graph C# Python Java Easy O(V+E) O(V)
KeysAndRooms C# Python Java Medium O(n) O(n)
Maximal Network Rank C++ C# Python Java Medium O(V+E) O(N^2logN)

Compression Algorithms

Title Solution Difficulty Time Space
LZ77 Python Medium O(n) O(n)

Math

Title Solution Difficulty Time Space
Integer to Roman C# Python Java Medium O(n) O(1)
Climbing Stairs C# Python Java Medium O(n) O(1)
Domino and Tromino Tiling C# Python Java Medium O(n) O(1)
Best Time to Buy and Sell Stock with Cooldown C# Python Java Medium O(n) O(1)
Count Odd Numbers in an Interval Range C# C++ Python Java Easy O(1) O(1)
Divide Two Integers C# C++ Python Java Medium O(log n) O(1)

Dynamic Programming

Title Solution Difficulty Time Space
Longest Common Subsequence C# Python Java Medium O(m*n) O(m*n)
As Far from Land as Possible Java Medium O(m*n) O(m*n)
Edit Distance C# Python Java Hard O(mn) O(n)
Generate Parentheses C# Python Java Medium O(n) O(n)
Combination Sum II C# Python Java Medium O(n) O(n)

Additional Practice

LeetCode Online is a website containing many algorithm questions. Most of them are real interview questions of Google, Facebook, LinkedIn, Apple, etc.