Please share your solutions - no matter whether it's O(1) space or O(n) space in the comments. I have added C++ and Java codes for both the approaches in the video.
@electricalcoder30254 жыл бұрын
Great content dude....keep moving...
@KnowledgeCenter4 жыл бұрын
Thanks, will do!
@adarshmv2614 жыл бұрын
Appreciate your effort sir.... can you please include python code as well instead of Java or C++
@KnowledgeCenter4 жыл бұрын
Haha. Will definitely try from next video. I hope nobody asks me for 4th language.
@lilacu4 жыл бұрын
Lol
@jaggujaggu29224 жыл бұрын
import itertools class Solution: def productExceptSelf(self, nums: List[int]) -> List[int]: l=[] k=list(itertools.combinations(nums,len(nums)-1)) def multiplyList(myList) : result = 1 for x in myList: result = result * x return(result) for i in k: l.append(multiplyList(i)) l=l[::-1] return(l) i am a begginer, bro can u help me with this code i am not able to pass all testcases
@KnowledgeCenter4 жыл бұрын
Your solution doesn't look O(n) time. In your code k is a list of all subsequences of n-1 length. Then you are iterating each list and multiplying. So, multiplying all elements of 1 list is O(n). So, do this for n lists. So, overall time complexity is O(nxn) = O(n2). All test cases will pass if you implement O(n) solution. Try avoiding many repeated multiplications, with the approach explained in video.