Best playlist over bit manipulation on entire youtube , I have completed it in just 1 day and its still 5 pm and i started on 9 am. The content was very enjoyable and gave me new ways to think using xor and many others . Thank you a lot for providing such a amazing content for FREE.❤❤❤
little modification requires for java : then it will pass all use case; long n = Math.abs((long)dividend); // Convert to long to handle Integer.MIN_VALUE long d = Math.abs((long)divisor); // Convert to long to handle Integer.MIN_VALUE
We can start our cnt from 32 (declared outside) and that way we won't have to increment it uptill 32, 31, 30... in order to find the point where ((d n) each time as the outer while loop iterates. This way we can simply keep decrementing cnt it until 0. Time complexity: O(32) which is as good as constant.
bro y did u delete the old string , heap, and other videos untill u upload new videos pls let the old one be there a kind ly request from ur student community pls understand us
Bhaiya sliding window v jldi lana i know apki schedule busy h but fir v wait kr rha hu 😅 Koi or playlist se pdh rha tha but waiting for yours sliding window playlist
This one works with 32 bit integers and is similar to Strivers solution: class Solution { public: int divide(int dividend, int divisor) { if(dividend == divisor) return 1; if (dividend == INT_MIN && divisor == -1) return INT_MAX; int sign = 1; if(dividend>=0 and divisor=d){ int cnt=0; while(n>d
Complete CPP Code: class Solution { public: int divide(int dividend, int divisor) { if(dividend==divisor) return 1; bool sign = true; if((dividend0) || (divisor=0)) sign = false; unsigned int n = abs(dividend); unsigned int d = abs(divisor); unsigned int ans = 0; while(n>=d){ short count=0; while(n > (d
Bro though this is good but the main gist of the problem is implemenation as well within the rules after knowing the logic, and by using long that rule has been broken
Below one slightly modified. public int divide(int dividend, int divisor) { // Check for edge cases if (dividend == 0) return 0; if (divisor == 0) throw new ArithmeticException("Division by zero"); if (divisor == -1 && dividend == Integer.MIN_VALUE) return Integer.MAX_VALUE; // Determine the sign of the result boolean isNegative = (dividend < 0) ^ (divisor < 0); // Convert dividend and divisor to positive values long absDividend = Math.abs((long) dividend); long absDivisor = Math.abs((long) divisor); long quotient = 0; while (absDividend >= absDivisor) { long temp = absDivisor; long shift = 1; // Shift the divisor left until it becomes greater than the dividend while ((temp
Thanks striver. I understand the solution but i just want to ask will it help in any other problems if i know this solution?Anyone? Your reply is appreciated.
Bhaiya, actually i want to start this DSA playlist but don't know from which video should i start as you have made playlists topicwise. It would really be helpful if you would create a new playlist and add all videos in order, else you can upload a seperate video regarding roadmap for this particular playlist, like from where one should start then what, then what, then next what.... --Thank you Please reply asap:-)
More efficient than Striver's code : T.C: O(1) S.C : O(1) int divideTwoInteger(int dividend, int divisor) { long q=0,sign=-1; if((dividend0)) sign=1; long d1=abs(dividend), d2=abs(divisor),temp=0; for(int i=31;i>=0;i--) { if((temp+(d2
Bhai mujhe English samajne me dikkat ho rahi ..and striver fails to say what he wants to do..like..in this..start ne bolte .. multiplication means continuous subtraction I give up with DSA..kitna rough hai... Best development haiii
can anyone plzz tell why this code is not working --> int division(int given, int divisor){ bool sign = true; // sign is positive if(given < 0 && divisor > 0) sign = false; // sign is negative if(given > 0 && divisor < 0) sign = false; // sign is negaitve long given1 = abs(given); long divisor1 = abs(divisor); long ans = 0; int cnt = 0; while( given1 - ( divisor1
I have a question, why are the we removing the largest possible first I mean why are we removing 12 first and then 6 and then 3...... we could have removed 3 and then 6 and then 12 (doing so will reduce the need to find what's the maximum that can be returned)............ after removing 3 (3 * 2^0) our n will 19, then we see that 6 (3 * 2^1) can be removed so we will remove 6, after removing 6 n becomes 13.... then we see that 12 (3 * 2^2) can be removed so we remove 12, then our n becomes 1, now the next thing that should be removed is 24 (3 * 2^3) .... but this cannot so we will return the sum of 1, 2 and 4 which is 7..... I tried this approach on the leetcode question 29, but it's giving TLE...... can someone please explain why..... I just reversed the order, right? this shouldn't cause TLE
C++ Solution - #include using namespace std; class Solution { public: int divide(int dividend, int divisor) { if (dividend == divisor) return 1; if (dividend == INT_MIN && divisor == -1) return INT_MAX; int sign = 1; if ((dividend >= 0 && divisor < 0) || (dividend 0)) { sign = -1; } long n = labs(dividend); // Use labs for long absolute value long d = labs(divisor); // Use labs for long absolute value long ans = 0; while (n >= d) { int cnt = 0; while (n >= (d
There is no need for nested loops TC - O(log2N) class Solution { public: int divide(int dividend, int divisor) { long c = 0; int sign = 0; if(dividend0) sign = 1; if(dividend>0 && divisor
So I wrote the code same as yours , got runtime error due to corner cases , Checked the solution 99% of solution have used long long which is violation of the question rules and then checked the LEE215 solution but it was working well in past not now , so can anyone provide me the solution which works well and follows the question rules too Edit : Got the solution here it is 👇👇 class Solution { public: int divide(int dividend, int divisor) { if (dividend == INT_MIN && divisor==-1) return INT_MAX; if(dividend==divisor)return 1; unsigned int n=abs(dividend),d=abs(divisor); bool neg=false; if(dividend =0)neg=true; else if(dividend >=0 && divisor=d){ short count=0; while(n > (d
Best playlist over bit manipulation on entire youtube , I have completed it in just 1 day and its still 5 pm and i started on 9 am. The content was very enjoyable and gave me new ways to think using xor and many others . Thank you a lot for providing such a amazing content for FREE.❤❤❤
W
Waiting for strings playlist
same! @Striver bhai please yaar
Yes we want string playlist
waiting for string playlist
Yep can't wait for string playlist
pls pls
Hello Striver
Thank you for Bit manipulation Series
Please make String Problems Solving series soon :)
yes, please make String problem series 🙏
little modification requires for java : then it will pass all use case;
long n = Math.abs((long)dividend); // Convert to long to handle Integer.MIN_VALUE
long d = Math.abs((long)divisor); // Convert to long to handle Integer.MIN_VALUE
thanks brother
Thanks
string matching algorithms would also help. Please make a playlist on that too.
The question requires not to use multiplication operator, but it is used in the last line:
n = n - (d * (1
We can start our cnt from 32 (declared outside) and that way we won't have to increment it uptill 32, 31, 30... in order to find the point where ((d n) each time as the outer while loop iterates.
This way we can simply keep decrementing cnt it until 0. Time complexity: O(32) which is as good as constant.
Exactly 💯
Thank you so so much.... I was eagerly waiting for the bit manipulation series.
amazing playlist..
its a humble request to bring a new stack & queue playlist as well
i didnt expect i wound complete this bit manipulation tipic in 4 hts in one sitting .. thank you sooo muchhh
Which college and which semester bro....
Thank you so much Striver you are motivating us to learn new topics by your videos. You are really doing great work!!
LGTA HAI RAJ BHAI AAJ HI BIT MANUPULATION KHATAM KR DENGE 😂😂😂😂😂😂😂😂. BUT SIR I HAVE MAD RESPECT FOR YOU 😊😊🫡🫡
Thanks I will complete till here by tomorrow
Thanks for this amazing playlist!
bro CAN U START STRING SERIES AS WELL PLZZZZZZZZZZZZZZZZZZZZZZZZZ
Great content 😁💯 waiting for string matching algorithms
add this link to a to z dsa sheet so that students can easily get it and thanks for uploading lectures
Heyy striver,
I have been learning from your videos and they are very nice.
I would request you to start string series please.
small doubt
why did we checked that quotient == 1
Amazing explaination Striver
thanks for such amazing playlist
Thank You So Much for this wonderful video.....🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻
Please continue the bit manipulation series 🙏
Understood, btw, innner while loop was O(1) as max is 32 only and it doesn't increase with size.
bro y did u delete the old string , heap, and other videos untill u upload new videos pls let the old one be there a kind ly request from ur student community pls understand us
Thank you @Striver respect++
we were not supposed to use multiplication, then how is this solution valid?
Thank you striver from bangladesh.
Please include 1915. Number of Wonderful Substrings, and it would be nice to cover the concept of masking in bit_manipulation series. Thanks.
this question is so bad, what does this even test? your mugging up skills?
Very good explaination thanks a lot Sir
Bhaiyaa please upload stack queue asap as well please 🥺
Great video 🔥
Thank you 😊
Bhaiya sliding window v jldi lana i know apki schedule busy h but fir v wait kr rha hu 😅 Koi or playlist se pdh rha tha but waiting for yours sliding window playlist
Most wanted topic❤
Bhaiya a2z sheet pa code and article ka link upload kar do binary search tree pa bhi kuch questions pa nahi hai ??
Striver bhai bit manipulation over, please do strings. It's very important, many questions are getting stuck in string. Please bhai🙏🙏
This one works with 32 bit integers and is similar to Strivers solution:
class Solution {
public:
int divide(int dividend, int divisor) {
if(dividend == divisor)
return 1;
if (dividend == INT_MIN && divisor == -1) return INT_MAX;
int sign = 1;
if(dividend>=0 and divisor=d){
int cnt=0;
while(n>d
Please start with string playlist sir
HUMBLE REQUEST TO YOU
Complete CPP Code:
class Solution {
public:
int divide(int dividend, int divisor) {
if(dividend==divisor)
return 1;
bool sign = true;
if((dividend0) || (divisor=0))
sign = false;
unsigned int n = abs(dividend);
unsigned int d = abs(divisor);
unsigned int ans = 0;
while(n>=d){
short count=0;
while(n > (d
Why unsigned int???
@@adityasrivastava3540 read the problem carefullly on LC
Thanks a lot 🙌
Please upload String Playlist also :)
Bro though this is good but the main gist of the problem is implemenation as well within the rules after knowing the logic, and by using long that rule has been broken
sir how to write good quality code uspe ak video banaya
best video
Awsm
Which college bro and which semester
Thankyou sir
is this the end of the playlist??
as there are some advance maths questions there in bit manipulation
class Solution {
public int divide(int dividend, int divisor) {
if(dividend == divisor) return 1;
boolean sign = true;
if(dividend0) sign = false;
if(dividend>0 && divisor=d){
int count = 0;
while(n>=(d
hey striver need a full combinatorics playlist...
Understood
Which college and which semester bro....
@@mdfaizanmdfaizan6041 i'm 12th bro
On the 2nd while condition, why does it not as n>= (d*(1
same as n >= (d
check his first video of bit manipulation in left shift
understood ❤
Java Solution:
class Solution {
public int divide(int dividend, int divisor) {
if(dividend == divisor) return 1;
boolean sign = true;
if(dividend0) sign = false;
if(dividend>0 && divisor=d){
int count = 0;
while(n>=(d
Thank you Bhaiya
Pls string playlist ❤❤❤
Below one slightly modified.
public int divide(int dividend, int divisor) {
// Check for edge cases
if (dividend == 0) return 0;
if (divisor == 0) throw new ArithmeticException("Division by zero");
if (divisor == -1 && dividend == Integer.MIN_VALUE) return Integer.MAX_VALUE;
// Determine the sign of the result
boolean isNegative = (dividend < 0) ^ (divisor < 0);
// Convert dividend and divisor to positive values
long absDividend = Math.abs((long) dividend);
long absDivisor = Math.abs((long) divisor);
long quotient = 0;
while (absDividend >= absDivisor) {
long temp = absDivisor;
long shift = 1;
// Shift the divisor left until it becomes greater than the dividend
while ((temp
waiting for the string playlist
Thanks striver.
I understand the solution but i just want to ask will it help in any other problems if i know this solution?Anyone? Your reply is appreciated.
Can be easily done in O(logn) too
Can anyone tell me, where is the link to the problem and notes, as i couldn't figure out where is day8 in the link given in description
isnt TC better for appr 1 , then why is appr 2 reqd ?
Bhaiya, actually i want to start this DSA playlist but don't know from which video should i start as you have made playlists topicwise. It would really be helpful if you would create a new playlist and add all videos in order, else you can upload a seperate video regarding roadmap for this particular playlist, like from where one should start then what, then what, then next what....
--Thank you
Please reply asap:-)
🔥
Which college and which semester bro....
very nice
understood
Which college and which semester bro....
More efficient than Striver's code :
T.C: O(1)
S.C : O(1)
int divideTwoInteger(int dividend, int divisor) {
long q=0,sign=-1;
if((dividend0))
sign=1;
long d1=abs(dividend), d2=abs(divisor),temp=0;
for(int i=31;i>=0;i--)
{
if((temp+(d2
Bhai mujhe English samajne me dikkat ho rahi ..and striver fails to say what he wants to do..like..in this..start ne bolte .. multiplication means continuous subtraction
I give up with DSA..kitna rough hai...
Best development haiii
First view from my sids 😊
the overflow part is still not that clear
can anyone plzz tell why this code is not working -->
int division(int given, int divisor){
bool sign = true; // sign is positive
if(given < 0 && divisor > 0) sign = false; // sign is negative
if(given > 0 && divisor < 0) sign = false; // sign is negaitve
long given1 = abs(given);
long divisor1 = abs(divisor);
long ans = 0;
int cnt = 0;
while( given1 - ( divisor1
striver please drop the strings playlist
what if our d is INT_MIN ?
ps : i didnt watch the whole lecture 😅
please start string series 🥺🥺🥺🥺🥺🥺
I have a question, why are the we removing the largest possible first I mean why are we removing 12 first and then 6 and then 3...... we could have removed 3 and then 6 and then 12 (doing so will reduce the need to find what's the maximum that can be returned)............ after removing 3 (3 * 2^0) our n will 19, then we see that 6 (3 * 2^1) can be removed so we will remove 6, after removing 6 n becomes 13.... then we see that 12 (3 * 2^2) can be removed so we remove 12, then our n becomes 1, now the next thing that should be removed is 24 (3 * 2^3) .... but this cannot so we will return the sum of 1, 2 and 4 which is 7..... I tried this approach on the leetcode question 29, but it's giving TLE...... can someone please explain why..... I just reversed the order, right? this shouldn't cause TLE
// Online C compiler to run C program online
#include
int main() {
int n;
int d;
scanf("%d %d",&n,&d);
int sum=0;
int count=0;
int ans=0;
while(sum
same doubt :/
@257divyanshu
These code is working in cpp but not in java
Greeting tle
Waiting for string
Java Solution : public class Solution {
public static int divideTwoInteger(int dividend, int divisor) {
if (dividend == divisor)
return 1;
boolean sign = true;
if (dividend > 0 && divisor < 0)
sign = false;
if (dividend < 0 && divisor > 0)
sign = false;
int n = Math.abs(dividend);
int d = Math.abs(divisor);
int ans = 0;
while (n >= d) {
int count = 0;
while (n >= (d
ans += (1
I just want to believe if the shift operators are used anywhere... 😢😢😢
yes it is too confuesing😅
❤
start heap playlist
C++ Solution -
#include
using namespace std;
class Solution {
public:
int divide(int dividend, int divisor) {
if (dividend == divisor) return 1;
if (dividend == INT_MIN && divisor == -1) return INT_MAX;
int sign = 1;
if ((dividend >= 0 && divisor < 0) || (dividend 0)) {
sign = -1;
}
long n = labs(dividend); // Use labs for long absolute value
long d = labs(divisor); // Use labs for long absolute value
long ans = 0;
while (n >= d) {
int cnt = 0;
while (n >= (d
I give up.... Developement isse acha haii
🙇🙇🙌
could have also used binary search, amirite//
There is no need for nested loops
TC - O(log2N)
class Solution {
public:
int divide(int dividend, int divisor) {
long c = 0;
int sign = 0;
if(dividend0) sign = 1;
if(dividend>0 && divisor
we didn't completely get away from using multiplication even with this code.
MAIN HOON MOHIT
2nd test case failed
Which college and which semester bro....
could have been better
Which college and which semester bro....
hail mary
Please stop wearing red and try other colors. Its boring now
Red increases attention and engagement of audience
Maybe that's why he always wears red for video making
taking long long 1LL menas ans += (1LL passed
if(ans > INT_MAX && sign == 0) return INT_MAX;
if(ans > INT_MAX && sign == 1) return INT_MIN;
code 2 => not passed
if(ans >= INT_MAX && sign == 0) return INT_MAX;
if(ans >= INT_MAX && sign == 1) return INT_MIN;
code 3 => not passed
if(ans >= (1 (1
So I wrote the code same as yours , got runtime error due to corner cases , Checked the solution 99% of solution have used long long which is violation of the question rules
and then checked the LEE215 solution but it was working well in past not now , so can anyone provide me the solution which works well and follows the question rules too
Edit : Got the solution here it is 👇👇
class Solution {
public:
int divide(int dividend, int divisor) {
if (dividend == INT_MIN && divisor==-1) return INT_MAX;
if(dividend==divisor)return 1;
unsigned int n=abs(dividend),d=abs(divisor);
bool neg=false;
if(dividend =0)neg=true;
else if(dividend >=0 && divisor=d){
short count=0;
while(n > (d
On the 2nd while condition, why does it not as n>= (d*(1
it is not possible, did not see any solution working with using int, you can use signed int, but that is violation as well
Understood
Which college and which semester bro....
waiting for strings playlist
Thank u sir
understood
Understood
understood