Max Dot Product of Two Subsequences | Leetcode 1458

  Рет қаралды 1,304

Ayushi Sharma

Ayushi Sharma

Күн бұрын

Time Complexity : O(n*m)
Space Complexity : O(n*m)
Problem Link : leetcode.com/p...
Python Code Link: github.com/Ayu...
Please like, share and subscribe if you found the video useful. Feel free to ask in comments section if you have any doubts. :)
#DataStructuresAndAlgorithms
#Leetcode
#interviewpreparation
#AyushiSharma
Max Dot Product of Two Subsequences solution
Max Dot Product of Two Subsequences Leetcode
Max Dot Product of Two Subsequences C++
Max Dot Product of Two Subsequences Java
Max Dot Product of Two Subsequences Python
🔥🔥🔥🔥👇👇👇
Join telegram channel for more updates on placement preparation : t.me/AyushiSha...
Checkout the series: 🔥🔥🔥
👉Interview Experiences : • Interview Experiences
👉 Array: • Arrays
👉 Linked List : • Linked List
👉 Heap : • Heap
👉 Recursion : • Recursion
👉 Stack and Queue : • Stack And Queue
👉 Greedy : • Greedy
👉 Dynamic Programming : • Dynamic Programming
👉 Leetcode contests : • Leetcode contests
👉 Leetcode June Challenge : • Leetcode June Challenge
👉 Leetcode July Challenge : • Leetcode July Challenge
LIKE | SHARE | SUBSCRIBE 🔥🔥😊

Пікірлер: 18
@vaibhavgupta973
@vaibhavgupta973 Жыл бұрын
thx
@AyushiSharmaDSA
@AyushiSharmaDSA Жыл бұрын
Welcome 😊
@bharatrajpurohit5300
@bharatrajpurohit5300 Жыл бұрын
Nice Explanation
@AyushiSharmaDSA
@AyushiSharmaDSA Жыл бұрын
thank you :)
@vision7673
@vision7673 10 ай бұрын
great explanation ma'am
@AyushiSharmaDSA
@AyushiSharmaDSA 8 ай бұрын
thank you :)
@pritz9
@pritz9 Жыл бұрын
Nice Explanation !
@AyushiSharmaDSA
@AyushiSharmaDSA Жыл бұрын
Thanks Prithwish😊
@subendernath
@subendernath Жыл бұрын
I've been recommending your videos to all my coding buddies. Keep 'em coming! 😊
@AyushiSharmaDSA
@AyushiSharmaDSA Жыл бұрын
Thank you Subender 😊
@ApnaVlogs-tj7do
@ApnaVlogs-tj7do Жыл бұрын
Optimised Solution ( Tabulation Approach ) 👇 class Solution: def maxDotProduct(self, nums1: List[int], nums2: List[int]) -> int: n = len(nums1) m = len(nums2) mini_num1 = 1e9 maxi_num1 = -1e9 mini_num2 = 1e9 maxi_num2 = -1e9 for num in nums1: if num > maxi_num1: maxi_num1 = num if num < mini_num1: mini_num1 = num for num in nums2: if num > maxi_num2: maxi_num2 = num if num < mini_num2: mini_num2 = num if (maxi_num1 < 0 and mini_num2 > 0) or (maxi_num2 < 0 and mini_num1 > 0): return max(maxi_num1*mini_num2,mini_num1*maxi_num2) dp = [[0]*(m+1) for i in range(n+1)] for ind1 in range(1,n+1): for ind2 in range(1,m+1): first = nums1[ind1-1] * nums2[ind2-1] + dp[ind1-1][ind2-1] second = 1 * dp[ind1][ind2-1] third = 1 * dp[ind1-1][ind2] dp[ind1][ind2] = max(first,second,third) return dp[n][m]
@Abhishek-ys2io
@Abhishek-ys2io Жыл бұрын
Finally video after long time.. why?
@vamsimadugula8524
@vamsimadugula8524 Жыл бұрын
we can also consider the case like we can not take both i and j also and making sure at last non empty ??
@ApnaVlogs-tj7do
@ApnaVlogs-tj7do Жыл бұрын
challenging part is to figure out how to handle the base case for [-1,-1] & [1,1] . rest is easy
@brawlstarsac3574
@brawlstarsac3574 Жыл бұрын
please explain in English
@callme_SRK
@callme_SRK Жыл бұрын
Mam can I get ur insta ID or mail ID?
@AyushiSharmaDSA
@AyushiSharmaDSA Жыл бұрын
Sure ayushisharma5141@gmail.com
@tofpgaming666
@tofpgaming666 Жыл бұрын
and password @@AyushiSharmaDSA
Maximum Profit in Job Scheduling | Leetcode 1235 | #ayushisharmaDSA
26:30
Maximum Product Subarray - Best Intuitive Approach Discussed
20:27
take U forward
Рет қаралды 271 М.
REAL OR CAKE? (Part 9) #shorts
00:23
PANDA BOI
Рет қаралды 81 МЛН
Can You Draw a Square With 3 Lines?
00:54
Stokes Twins
Рет қаралды 53 МЛН
When my son wants to eat KFC #shorts #trending
00:46
BANKII
Рет қаралды 27 МЛН
C can do this too and it's faster than Python
2:09:48
Tsoding Daily
Рет қаралды 28 М.
Recursion Subset, Subsequence, String Questions
1:23:56
Kunal Kushwaha
Рет қаралды 356 М.
5 Simple Steps for Solving Any Recursive Problem
21:03
Reducible
Рет қаралды 1,3 МЛН
REAL OR CAKE? (Part 9) #shorts
00:23
PANDA BOI
Рет қаралды 81 МЛН