L4. Power Set | Bit Manipulation

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

never thought this problem can be solved by this approach

sachinvarma
Автор

This problem looks very easy from explanation but after he writes code and mapping back to explanation you will know how tricky it is....
Kudos to you for putting this explanation and solution....

santoshkumak
Автор

No one can explain this with that ease..wonderful 👏🏼👏🏼👏🏼👏🏼

arnabnath
Автор

mjhe to khud pe pura beleive hai ki kv na soch pata mai ye blowing striver

raghavmanish
Автор

Brother i have my placement in 3 months plz continue this playlist

nishchaypandit
Автор

broo, i came after that recursion playlist only, there you are telling to watch bit manipulation playlist and here you are telling to watch recursion playlist🤭🤭😂🤣, btw you are the best thooo

jagadeesh
Автор

the observation that take set bit of 2^n index in input array as member of a subset is very theoretical & observation intensive and hard to come up with, if we have seen never before, how to deal with it @take U forward

sshv
Автор

striver its really deep knowledge .its hard to understand but code is simple and couple of lines.However understood boss.

sarder
Автор

00:04 Printing all subsets using power set technique
01:37 Power set is the number of subsets
03:16 Using simple Boolean logic to generate power set
04:54 Creating subsets using bit manipulation
06:27 Iterate and generate subsets using bit manipulation.
07:59 Generating power set using bit manipulation
09:34 Generating power set using bit manipulation.
11:14 Discussing space complexity and subset sizes in power set generation.

GopalGangoriya
Автор

nums=[1, 2, 3]
length=len(nums)
upper=(2**length)-1
sup_set=list()
for i in range(upper, -1, -1):
ans=list()
for j in range(length):
mask=1<<j
if i&mask : ans.append(nums[j])

sup_set.append(ans)
print(sup_set)

vishnupandey
Автор

c++ code
class Solution {
public:
vector<vector<int>> subsets(vector<int>& nums) {
int n = nums.size();
int subsett = 1 << n;
vector<vector<int>> ans;
for(int num = 0; num < subsett; num++) {
vector<int> list;
for(int i = 0; i < n; i++) {
if(num & (1 << i)) {
list.push_back(nums[i]);
}
}
ans.push_back(list);
}
return ans;
}
};

AbhishekSharma-
Автор

fan eko naar daa mai, das vaari vaarda mai, ohde utton 100-100 diyaan gatthiyaan. Time laggu mitne nu, saanu thalle sittne nu, ikki vaari zor laale chattiyaan!

jacobblack
Автор

Which approach is better, recursive or bitwise one?

siddheshpandey
Автор

Bruh, wonderful!, sorry I did not subscribe until now, i mean im following u from a yr, but never saw the subscribe button idk how. uff. DID IT NOW :)

ajayprabhu
Автор

public static void main(String[] args) {
int[] nums = {1, 2, 3};
int subsets = 1<<nums.length;
ArrayList<ArrayList<Integer>> al = new ArrayList<>();
for(int i=0;i<subsets;i++){
ArrayList<Integer> subal = new ArrayList<>();
for(int j=0;j<nums.length;j++){
if((i&(1<<j))!=0){
subal.add(nums[j]);
}
}
al.add(subal);
}
System.out.println(al);

unoshihaam
Автор

Python code:

class Solution:
def subsets(self, nums: List[int]) -> List[List[int]]:
subset= (1<<len(nums))
ans=[ ]
for i in range(0, subset):
list=[ ]
for j in range(len(nums)):
if i & (1<<j) !=0:
list.append(nums[j])

ans.append(list)
return ans

arushikapoor
Автор

what if the interviewer asks about the intuittion

aditiapar
Автор

Bhiya ab india aa gaye ho video ki consistancy banae rakhna

shubham