Don't know what Leetcode smoked before placing this question in a Medium Category 🥵!! Checkout DSA-169 Series: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-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!!!
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 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; } };
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.✌️