Don't know what Leetcode smoked before placing this question in a Medium Category 🥵!! Checkout DSA-169 Series: ruclips.net/video/5BuKVS-Vnws/видео.html Problem Link: leetcode.com/problems/single-number-ii/description/ Code & Notes: drive.google.com/file/d/1-f0XzUitIZ-U0ieKkomuyK_xUhulAttG/view?usp=sharing
After looking Leetcode solutions section and not understanding the intuition behind the bit manipulation approach, I came here and simply got the intuition behind that very easily. Thanks a lot for explaining the links and thought process Aryan!!!
class Solution { public: int singleNumber(vector& nums) { int ones=0, twos=0; for(int n: nums){ ones = (ones ^ n) & ~twos; // frequency is 0 and not 2 twos = (twos ^ n) & ~ones; // frequency is 2 and not 1 } return ones; } };
Thank you so much, I have been looking for the last approach explanation specifically for the last 3 days. Your way of explaining the things and your passion are amazing.
class Solution { public: int singleNumber(vector& nums) { int n = nums.size(), ans = 0; for (int i = 0; i < 32; i++) { int sum = 0; for (int j = 0; j < n; j++) { sum += (nums[j] >> i) & 1; } sum = sum % 3; ans = ans | (sum
i have one question like i was doing dry and run on array [5,5,5,6,4,4,4] after when array element first 4 comes if gtes xor with what ones contains so it technically has 6 bcoz it occured ones then when we xor 6^4 it will not remain 6 pls tell me what im doing wrong something is off i cant pinpoint pls help folks!!
class Solution { public: int singleNumber(vector& nums) { int n = nums.size(), ans = 0; for (int i = 0; i < 32; i++) { int sum = 0; for (int j = 0; j < n; j++) { sum += (nums[j] >> i) & 1; } sum = sum % 3; ans = ans | (sum
@@noobnessmee it's very easy to say anything about anyone, you should thanks him for such unique content on YT which no one explains the concept in such depth (and that you also know that's why you are here watching his videos 😛). It's easy to comment on someone, try it on your own you will realise it. And his expressions speaks how much dedicated he his with his work.✌️
Don't know what Leetcode smoked before placing this question in a Medium Category 🥵!!
Checkout DSA-169 Series: ruclips.net/video/5BuKVS-Vnws/видео.html
Problem Link: leetcode.com/problems/single-number-ii/description/
Code & Notes: drive.google.com/file/d/1-f0XzUitIZ-U0ieKkomuyK_xUhulAttG/view?usp=sharing
One of the best best RUclipsr who can explain any hard problem easy thanky Aryan we will remember you for ever because your making our lives better
I guess, at 7:44 you mean to check 3*1e4 for N and not 2^31 because the N is the size of the input, not the range of numbers...
Yeah exactly
After looking Leetcode solutions section and not understanding the intuition behind the bit manipulation approach, I came here and simply got the intuition behind that very easily.
Thanks a lot for explaining the links and thought process Aryan!!!
Thank you, Aryan! It's a beautiful video. Helped me improve my thought process. Glad that I came across your channel.
beautifully explained.......................the only person on the whole internet who teaches how to build the solution❤❤
Loved the way you explained bro, best video for this question i found so far!!
My favorite man. Thanks, man
class Solution {
public:
int singleNumber(vector& nums) {
int ones=0, twos=0;
for(int n: nums){
ones = (ones ^ n) & ~twos; // frequency is 0 and not 2
twos = (twos ^ n) & ~ones; // frequency is 2 and not 1
}
return ones;
}
};
Why the solution 3 doesn't work for negative numbers
Thank you so much, I have been looking for the last approach explanation specifically for the last 3 days. Your way of explaining the things and your passion are amazing.
you're underrated
great work
Nice idea of encapsulating the set bits that have come once and twice and then modifying them🔥
did you tried to submit your 3rd intution code ? as the number can be negative this intution will not work
Yes, it is not working for negative numbers
class Solution {
public:
int singleNumber(vector& nums) {
int n = nums.size(), ans = 0;
for (int i = 0; i < 32; i++) {
int sum = 0;
for (int j = 0; j < n; j++) {
sum += (nums[j] >> i) & 1;
}
sum = sum % 3;
ans = ans | (sum
Great bhai
Loved the approach and how you got to it.. Loved it Thanks......
Mind blowing explanation 💫. The last approach is so amazing . You are very good at this explanatory work . ❤
Loved the approach bro !
Thanks for the video
Last approach was ❤
i start my day with solving leetcode problem of the day , and then during breakfast i watch your solution video , love your videos.
Best Explanation but sound is not Clear
You earned a sub ! Kudos to your hard work !!!
how bit manipulation is taking place pls help im doing dr and run im not getting?
It was nice one !
i have one question like i was doing dry and run on array [5,5,5,6,4,4,4] after when array element first 4 comes if gtes xor with what ones contains so it technically has 6 bcoz it occured ones then when we xor 6^4 it will not remain 6 pls tell me what im doing wrong something is off i cant pinpoint pls help folks!!
array needs to be sorted i guess
approach 4 is lit
Aryan can u make complete video dedicated to bit manipulation?
thanks.
salute
Please solve longest palindromic subsequence leetcode -2484
#include
using namespace std;
int singleNumII(vector a,int n)
{
int ones=0,twos=0;
int i;
for(i=0;i
class Solution {
public:
int singleNumber(vector& nums) {
int ans = 0;
for(int i=0;i
It doesn't work for negative numbers
class Solution {
public:
int singleNumber(vector& nums) {
int n = nums.size(), ans = 0;
for (int i = 0; i < 32; i++) {
int sum = 0;
for (int j = 0; j < n; j++) {
sum += (nums[j] >> i) & 1;
}
sum = sum % 3;
ans = ans | (sum
too much for me ! 😢
forrr 22222
38 min video 🤦🏻♂️. Who's gonna waste time.. why can't you make under 20 min video or split the video
why can't you check timestamp and skip to the part u need, you don't need to watch all 4 approaches
same lol, i'm waiting for neetcode to start uploading again, till then will have to make do with him.
he can just cut his overactting and video would be 20 mins lol
Why are you saying that? If you don't enjoy it, simply choose not to watch it. You may inadvertently demotivate him from creating more content.
@@noobnessmee it's very easy to say anything about anyone, you should thanks him for such unique content on YT which no one explains the concept in such depth (and that you also know that's why you are here watching his videos 😛). It's easy to comment on someone, try it on your own you will realise it. And his expressions speaks how much dedicated he his with his work.✌️