0% found this document useful (0 votes)
21 views

Coding_Notes_SDE_Blind75_Neetcode_Ashhad

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Coding_Notes_SDE_Blind75_Neetcode_Ashhad

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 18

Problem 1: Best time to buy and sell stock

https://www.youtube.com/watch?v=34WE6kwq49U

https://leetcode.com/problems/best-time-to-buy-and-sell-stock/solutions/3914105/most-optimized-
solution-easy-to-understand-c-java-python/

a= [5,2,6,1,4]

Problem 2: Two Sum

https://leetcode.com/problems/two-sum/solutions/3619262/3-method-s-c-java-python-beginner-
friendly/

Two Sum: Complexity O(nlogn) if we use a map O(n) if we use unordered map in best and average
case O(N^2) in worst case
JAVA
Python

Problem 3: https://leetcode.com/problems/product-of-array-except-self/description/

Problem 4:

https://leetcode.com/problems/contains-duplicate/description/
https://leetcode.com/problems/contains-duplicate/solutions/3672475/4-method-s-c-java-python-
beginner-friendly/

Problem 5: Maximum subarray https://leetcode.com/problems/maximum-subarray/


Problem 6: 3 sum

Below solution works for all tc’s but TLE error for really big arrays.
Optimized solution:

Binary:

No:of bits which are set in a number

both loops gives same output


Problem 1: https://leetcode.com/problems/reverse-bits/description/
same as above

https://leetcode.com/problems/reverse-bits/solutions/5215314/reverse-bits-easy-o-1-solution-with-
0ms-runtime/

https://leetcode.com/problems/reverse-bits/solutions/1232842/java-c-0ms-o-1-time-complexity-in-
place-detailed-explanation/
Problem 2: https://leetcode.com/problems/sum-of-two-integers/

We cannot use b>0 in the


loop because it can be negative.

https://leetcode.com/problems/sum-of-two-integers/solutions/4326325/c-beats-100-bit-
manipulation-maths/

Problem 3: https://leetcode.com/problems/reverse-integer/
Problem 4: https://leetcode.com/problems/powx-n/
If we use for(int i=0;i<n;i++) here it will give TLE

https://leetcode.com/problems/powx-n/solutions/3206602/best-c-5-solution-math-recursion-brute-
force-optimize-one-stop-solution/

Problem 5: https://leetcode.com/problems/happy-number/

https://leetcode.com/problems/happy-number/solutions/2969127/fastest-c-solution-using-
recursion/

Problem 6: https://leetcode.com/problems/plus-one/solutions/

https://leetcode.com/problems/plus-one/solutions/5036558/beats-100-runtime-and-54-32-
memory-c-easy-to-understand/
Matrix:

Problem 1: https://leetcode.com/problems/rotate-image/description/
Problem 2: https://leetcode.com/problems/set-matrix-zeroes/

https://takeuforward.org/data-structure/set-matrix-zero/

Extra Space:
No extra Space and using 0th row and 0th column to store flags but the thing is that matrix[0][0]
element is common for both 0th row and 0th column . So to avoid 0th column to become 0 due to 0
obtained from other columns in the first row(other than 0) we use col0 variable to track first column.

Strings:
Problem1: https://leetcode.com/problems/valid-anagram/
JAVA:-
Question 2: https://leetcode.com/problems/valid-palindrome/description/

For alphanumerics we can also use ch>=’a’&&ch<=’z’ || ch<=’9’&&ch>=’0’||ch>=’A’&&ch<=’Z’


Question 3:- https://leetcode.com/problems/longest-substring-without-repeating-characters/
description/

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy