Skip to content

Solutions to coding problems of Java, Python and SQL that can occur through high-tier interviews or while implementing algorithms used here in daily jobs & preparation advices for interviews.

License

aurimas13/Solutions-To-Problems

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Welcome to the Amazing World of Solutions! 🎉🎩🔮

Brace yourself as we dive into the most common solutions to problems from interviews of high-tier companies.

Featuring dazzling Python, Java, SQL & Pandas Solutions to challenges on LeetCode & HackerRank.


python java sql lastcommit stars twitter twitter


📢 Roll up, roll up! Welcome to the grand repository of brilliant code solutions. Constantly updated with enchanting Python, Java, SQL or Pandas solutions to bewitching problems found at LeetCode (mostly) or HackerRank. Share the thrill as we unravel the mysteries of high-tier companies like Google, Meta, Amazon, Apple, Spotify, and more!

🎪 Behold the mesmerizing progress of the LeetCode account, sprinkled with magical blog posts providing explanations on select solutions. Gaze upon it here.

🎡 Marvel at the colorful array of LeetCode solutions in Python - here, HackerRank solutions in Python - here, LeetCode solutions in Java - here and LeetCode SQL Solutions as well as LeetCode Pandas Solutions and be fascinated by some videos of how I tackled problems here.

🔮 Each problem folder unveils the description of the problem and, sometimes, the solution and explanation. Click the name of the problem in the Problems and Solutions, Must Do Problems or Google Top to reveal its secrets.

🎭 Currently enchanting the world with Python & a touch of Java from LeetCode with a hand in SQL and sometimes Pandas. A daily Python problem from LeetCode has been vanquished since 28th of May 2022 and a daily Java solution also is being addded since 19th May 2023.

🎠 The magic continues with SQL & Pandas solutions of problems at HackerRank & LeetCode, coming soon to HackerRank SQL Solutions while now doing LeetCode SQL Solutions and LeetCode Pandas Solutions.

Table of Contents

Preparation for Interviews

(Back to top)

🎩 To prepare for a mystical journey through a MAANG interview or a MAANG-level company interview and land a job in the enchanted realm of tech giants, we highly recommend the following spells:

  1. Solve as many problems from our mesmerizing list as possible.
  2. Join the mystical Hackpack community to learn the art of sorcery from fellow wizards.
  3. Conjure your skills by solving the Top LeetCode Problems.
  4. Master the incantations of Python Skills.
  5. Test your wit with Multiple Choice Questions to prove your magical prowess. Embrace the magical journey of interview preparation, and may your code be ever enchanting! 🌟🌈🔮

Problems and Solutions

There are over 500 solutions of all four languages of Python - here, Java - here Pandas - here and SQL - here with details which problems are solved at the particular folder.

Total Number

Total number of LeetCode solutions per company are shown below:*

Company Name Total Solutions
Amazon 382
Google 373
Apple 317
Facebook 319
Microsoft 295
Bloomberg 273
Adobe 268
Uber 231
Goldman Sachs 194
TikTok 146
LinkedIn 121
Airbnb 95
Tesla 84
Twitter 72
DE Shaw 42
Spotify 38
Reddit 21
Netflix 10
Others 706


* Updated daily. Details of the problems that belong to a specific company are linked to it.


Must Do Problems

(Back to top)

No. Question Solution Time Complexity Space Complexity
1 Two Sum Two Sum O(n) O(n)
2 Merge Two Sorted Lists Merge Two Sorted Lists O(n) O(n)
3 Merge k Sorted Lists Merge k Sorted Lists O(n log n) O(1)
4 Best Time to Buy and Sell Stock Best Time to Buy and Sell Stock O(n) O(1)
5 Reverse Bits Reverse bits O(1) O(1)
6 Number of 1 Bits Number of 1 bits O(log n) O(1)
7 Contains Duplicate Contains Duplicate O(n) O(n)
8 Meeting Rooms Meeting Rooms O(n log n) O(1)
9 Missing Number Missing Number O(n) O(1)
10 Counting Bits Counting bits O(n log n) O(n)
11 Merge Intervals Merge Intervals O(n log n) O(n)
12 Insert Interval Insert Interval O(n) O(n)
13 Valid Palindrome Valid Palindrome O(n) O(n)
14 Valid Parentheses Valid Parentheses O(n) O(n)
15 Climbing Stairs Climbing Stairs O(n) O(n)
16 Same Tree Same Tree O(log n) O(1)
17 Maximum Depth of Binary Tree Maximum Depth of Binary Tree O(n) O(n)
18 Linked List Cycle Linked List Cycle O(n) O(n)
19 Reverse Linked List Reverse Linked List O(n) O(n)
20 Invert Binary Tree Invert Binary Tree O(n) O(1)
21 Valid Anagram Valid Anagram O(n) O(n)
22 Lowest Common Ancestor of a Binary Search Tree Lowest Common Ancestor of a Binary Search Tree O(n) O(1)
23 Subtree of Another Tree Subtree of Another Tree O(n^2) O(n)
24 Combination Sum Combination Sum O(2^n) O(n)
25 Container With Most Water Container With Most Water O(n) O(1)
26 3Sum 3Sum O(n^2) O(n)
27 Longest Substring Without Repeating Characters Longest Substring Without Repeating Characters O(n) O(n)
28 Longest Palindromic Substring Longest Palindromic Substring O(n^2) O(1)
29 Rotate Image Rotate Image O(n^2) O(1)
30 Search in Rotated Sorted Array Search in Rotated Sorted Array O(log n) O(1)
31 Word Search Word Search O(n^2) O(n)
32 Word Break Word Break O(n^2) O(n)
33 Number of Islands Number of Islands O(n^2) O(n^2)
34 Coin Change Coin Change O(n^2) O(n)
35 Course Schedule Course Schedule O(n) O(n)
36 Decode Ways Decode Ways O(n) O(n)
37 House Robber House Robber O(n) O(1)
38 Group Anagrams Group Anagrams O(n) O(n)
39 Find the Duplicate Number Find the Duplicate Number O(n) O(n)
40 Find Minimum in Rotated Sorted Array Find Minimum in Rotated Sorted Array O(log n) O(1)
41 Sum of Two Integers Sum of Two Integers O(1) O(1)
42 Maximum Subarray Maximum Subarray O(n) O(n)
43 Set Matrix Zeroes Set Matrix Zeroes O(n^2) O(n)
44 Maximum Product Subarray Maximum Product Subarray O(n) O(n)
45 Longest Consecutive Sequence Longest Consecutive Sequence O(n log n) O(1)
46 Palindromic Substrings Palindromic Substrings O(n^2) O(n^2)
47 Spiral Matrix Spiral Matrix O(n^2) O(n^2)
48 Product of Array Except Self Product of Array Except Self O(n) O(n)
49 Graph Valid Tree Graph Valid Tree O(n) O(n)
50 Unique Paths Unique Paths O(n^2) O(n^2)
51 Minimum Window Substring Minimum Window Substring O(n) O(n)
52 Remove Nth Node From End of List Remove Nth Node From End of List O(n) O(1)
53 Jump Game Jump Game O(n^2) O(1)
54 Reorder List Reorder List O(n) O(n)
55 Validate Binary Search Tree Validate Binary Search Tree O(n) O(n)
56 Binary Tree Level Order Traversal Binary Tree Level Order Traversal O(n) O(n)
57 Construct Binary Tree from Preorder and Inorder Traversal Construct Binary Tree from Preorder and Inorder Traversal O(n) O(n)
58 Clone Graph Clone Graph O(n) O(n)
59 Kth Smallest Element in a BST Kth Smallest Element in a BST O(n) O(n)
60 Encode and Decode Strings Encode and Decode Strings O(n) O(n)
61 Design Add and Search Words Data Structure Design Add and Search Words Data Structure O(n) O(n)
62 Serialize and Deserialize BST Serialize and Deserialize BST O(n) O(n)
63 Longest Common Subsequence Longest Common Subsequence O(n) O(n)
64 Longest Increasing Subsequence Longest Increasing Subsequence O(n^2) O(n)
65 Pacific Atlantic Water Flow Pacific Atlantic Water Flow O(n^2) O(n^2)
66 Top K Frequent Elements Top K Frequent Elements O(n) O(n)
67 Longest Repeating Character Replacement Longest Repeating Character Replacement O(n) O(1)
68 Non-overlapping Intervals Non-overlapping intervals O(n) O(n)
69 Number of Connected Components in an Undirected Graph Number of Connected Components in an Undirected Graph O(log n) O(n)
70 Alien Dictionary Alien Dictionary O(n log n) O(n)
71 Lowest Common Ancestor of a Binary Tree Lowest Common Ancestor of a Binary Tree O(n) O(1)
72 Implement Trie (Prefix Tree) Implement Trie (Prefix Tree) O(n) O(n)
73 House Robber II House Robber II O(n) O(n)
74 Meeting Rooms II Meeting Rooms II O(n log n) O(n)
75 Word Search II Word Search II O(n^2) O(n^2)
76 Binary Tree Maximum Path Sum Binary Tree Maximum Path Sum O(n) O(n)
77 Find Median from Data Stream Find Median from Data Stream O(log n) O(n)

Google Top

(Back to top)

No. Question Solutiion Time Complexity Space Complexity
1 Two Sum Two Sum O(n) O(n)
2 Maximal Rectangle Maximal Rectangle O(n) O(n)
3 Insert Interval Insert Interval O(n) O(n)
4 X of a Kind in a Deck of Cards X of a Kind in a Deck of Cards O(n log n) O(n)
5 Maximal Square Maximal Square O(n^2) O(n^2)
6 Bulls and Cows Bulls and Cows O(n) O(1)
7 Evaluate Division Evaluate Division O(n^2) O(n^2)
8 Decode String Decode String O(n) O(n)
9 Longest String Chain Longest String Chain O(n log n) O(n)
10 Validate Stack Sequences Validate Stack Sequences O(n) O(n)
11 Minimum Window Substring Minimum Window Substring O(n) O(n)
12 The Skyline Problem The Skyline Problem O(n log n) O(n)
13 Longest Increasing Path in a Matrix Longest Increasing Path in a Matrix O(n^2) O(n^2)
14 Find Median from Data Stream Find Median from Data Stream O(log n) O(n)
15 Count of Smaller Numbers After Self Count of Smaller Numbers After Self O(n log n) O(n)
16 Network Delay Time Network Delay Time O(n log n) O(n)
17 Subarray Sum Equals K Subarray Sum Equals K O(n) O(n)
18 Max Sum of Rectangle No Larger Than K Max Sum of Rectangle No Larger Than K n log(n) O(n)
19 Split Array into Consecutive Subsequences Split Array into Consecutive Subsequences O(n) O(n)
20 Split Array Largest Sum Split Array Largest Sum O(log n O(1)
21 Minimum Domino Rotations For Equal Row Minimum Domino Rotations For Equal Row O(n) O(1)
22 Random Pick with Weight Random Pick with Weight O(log n) O(n)

License

LICENSE