Skip to content

harshulab/LeetCode-Solutions

This branch is 1 commit ahead of, 137 commits behind sankalpdayal5/LeetCode-Solutions:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

3147a34 ยท Oct 20, 2020

History

63 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LeetCode Solutions

Find video link at my YouTube channel
Or from the Sheet 1 of this Google Sheet

Languages Used - Java and Python3

# Title Solution Code Time Space Difficulty Tags Video
0027 Remove Element Two pointers for counting valid nos and swapping Java Python O(n) O(1) Easy Array Two Pointers ๐Ÿ“บ
0053 Maximum Subarray Parse array and save the best solution at each step Java O(n) O(1) Easy Array Dynamic Programming
0055 Jump Game Iterate from last index and check if we can reach there from current index or not Python O(n) O(1) Medium Array Greedy ๐Ÿ“บ
0100 Same Tree Check isSame(node.left) and isSame(root.right) Java O(n) O(h) Easy Tree Depth-first-Search ๐Ÿ“บ
0101 Symmetric Tree Check if left.left==right.right and left.right==right.left Java O(n) O(h) Easy Tree Depth-first-Search Breadth-first-Search ๐Ÿ“บ
0104 Maximum Depth of Binary Tree Depth = 1 + Max(depth of left, depth of right) Java O(n) O(h) Easy Tree Depth-first-Search ๐Ÿ“บ
0121 Best time to buy and sell stock Minimize Cost price and Maximise Profit Java O(n) O(1) Easy Array Dynamic Programming ๐Ÿ“บ
0268 Missing Number Assuming that XOR is a constant-time operation, this algorithm does constant work on nn iterations, so the runtime is overall linear C++ O(n) O(1) Easy Array Math BitManipulation
0283 Move Zeroes Two pointers for counting valid nos and swapping Java O(n) O(1) Easy Array Two Pointers ๐Ÿ“บ
0287 Find duplicate in array of N+1 numbers Find the cycle using slow and fast pointer Java O(n) O(1) Medium Array Two Pointers
0451 Sort Characters By Frequency LeetCode Github Java Python O(n) O(n) Medium Hash Table Heap
0509 Fibonacci Number Storing the value of two previous number and updating them Java O(n) O(1) Easy Array ๐Ÿ“บ
0647 Palindromic Substrings Extend from center, 2 function call for odd and even palindromes Java O(n^2) O(1) Medium String Dynamic Programming ๐Ÿ“บ
0695 Max Area of Island Apply DFS on the Gird by exploring every square connected to it 4-directionally, total number of squares explored will be the area of that connected shape. C++ O(Rโˆ—C) O(Rโˆ—C) Medium Depth-First-Search
1347 Minimum Number of Steps to Make Two Strings Anagram Add 1 for char in s and remove 1 for char in t Java O(n+m) O(1) Medium Hash Table Heap ๐Ÿ“บ
1352 Product of the Last K Numbers Add new element to list by multiplying it with previous number and return arr[n-1]/arr[n-k-1] Python O(1) O(1) Medium Array Design ๐Ÿ“บ

Format

0000 Ques name Algo Java O() O() Easy Category ๐Ÿ“บ
0000 Ques name Algo Java O() O() Easy Category ๐Ÿ“บ

Made with Python Made with Java Made with C++

Built with love

About

:octocat: (Daily Update) Java / Python Solutions of LeetCode Problems

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 70.2%
  • Python 23.5%
  • C++ 6.3%