Sum of Two Integers - Leetcode 371 - Java

Поділитися
Вставка
  • Опубліковано 24 лис 2024

КОМЕНТАРІ • 183

  • @NeetCode
    @NeetCode  3 роки тому +113

    ok fine, I will compromise and start doing my videos in C 😉

    • @mama1990ish
      @mama1990ish 3 роки тому +63

      No please use python going forward. I religiously follow all your videos :) both for the explanation and because I like coding in python.

    • @ShivamJha00
      @ShivamJha00 3 роки тому +5

      Why would you torture yourself like that

    • @dataman4503
      @dataman4503 3 роки тому +2

      may be just pseudo code. lol

    • @maxmarkensten8841
      @maxmarkensten8841 3 роки тому +1

      I'd still watch :D

    • @johns3641
      @johns3641 3 роки тому +13

      Love that you completed all the vids for blind 75, but only use python for your codes. I have plenty of other people I could go to for C, so don't do any other language. Python only - that's your niche and why most people are here.

  • @sysy2152
    @sysy2152 2 роки тому +233

    If you want to do the same thing in Python, you can use this code (and I'll explain it!):
    class Solution:
    def getSum(self, a: int, b: int) -> int:
    mask = 0xffffffff
    while b != 0:
    tmp = (a & b) mask // 2:
    return ~(a ^ mask)
    else:
    return a
    To explain, the hexadecimal number 0xffffffff is the same as the binary number 0b1111111111111111111111111111111, containing 32 1's. (It's just easier to type lol.)
    In order to make the code work like Java, we want to treat our numbers like they only have 32 bits. ANDing a number with the mask 0xffffffff, or 32 1's, basically turns all of a number's bits into 0's except for the rightmost 32. As a result, the number can be represented as if it only has 32 bits.
    We do what Neetcode describes in his video, using XOR for the sum and AND for the carry. We AND with the mask each time we set a and b in order to keep our numbers within 32 bits.
    After we exit the while loop, we have our answer a. If a is positive, then we can return it directly. However, in Python, negative numbers are represented in binary as having an unlimited number of leading 1's. The current answer would only have values in the rightmost 32 bits. Therefore, if the answer is negative, we need to convert it into Python's representation of negative numbers.
    First, we need to check if the answer is negative. We cannot just check to see if the answer is less than zero because our representation of the answer is not the same as Python's (since Python's have unlimited leading 1's). We are still treating our answer as if it only fits into 32 bits.
    A 32-bit signed integer is positive if the 32nd bit is a 0 and is negative if the 32nd bit is a 1. If we divide our mask (0xffffffff) by 2, we will get the binary number 0b0111111111111111111111111111111, which has 31 1's. This number is the greatest value we can have before the 32nd bit becomes a 1. Therefore, if our answer a > mask // 2, it is negative. Otherwise, it is positive and we can just return a itself.
    If the number is negative, we then need to convert it into Python's representation of negative numbers. To do so, we can XOR with the mask of 32 1's in order to flip the rightmost 32 bits, since XORing a bit with 1 flips the bit. We can then NOT the number in order to turn all of the leading 0's into 1's. For example, say that the answer is -3, and (....0000000) or (....1111111) denote leading 0's or 1's until the 32nd bit:
    Our representation of -3 in 32 bits: (...0000000)11111111111111111111111111111101
    XOR with mask, aka flip rightmost 32 bits: (...0000000)00000000000000000000000000000010
    NOT, aka flipping all bits: (...1111111)1111111111111111111111111111101
    The result is Python's representation of -3, including an unlimited number of leading 1's.
    Overall, the code uses the same process as Neetcode's Java code, but with masking to get numbers into 32 bits and some manipulation to get those 32-bit numbers back into Python's representation before returning.

    • @eeew2691
      @eeew2691 2 роки тому +5

      Man how tf do u know all this stuff. My code was failing to add -8 and -12, and here I was thinking what to do with -ve integers T_T. Having a non IT background surely makes it difficult

    • @anonymoustv8604
      @anonymoustv8604 2 роки тому +28

      @@eeew2691 nah, this is hard even for people with IT background :)

    • @nick_esqueda
      @nick_esqueda 2 роки тому +3

      thank you man, i really appreciate the in depth explanation!!! this forced me to learn a little more about python today lol, i don't ever think about how integers are stored in languages and stuff so this was kind of cool to dive into.

    • @lingzi6599
      @lingzi6599 2 роки тому

      Is there a simpler solution for Python? If not, does this mean that Python is not good for handling binary operation?

    • @sysy2152
      @sysy2152 2 роки тому +6

      @@lingzi6599 Unfortunately, since Python stores its integers in a different way than Java, all of this solution's parts are necessary. Python is as capable as any other language for handling binary operations, but in interviews (and beyond) it can be important to remember that Python represents its integers as having more than 32 bits. In many problems, remembering the bitmask of 0xffffffff can save you if you choose to use Python!

  • @sia1910
    @sia1910 3 роки тому +90

    Please use python too in your future vids! There are many java based channels, but yours is the only good python channel that I could find

    • @gunahawk6893
      @gunahawk6893 2 роки тому +1

      @@caaarbz so is python, with ml and ai python will become top 2 soon

    • @NK-fe3md
      @NK-fe3md 2 роки тому

      @@gunahawk6893 What ?, its already the 2nd most popular only behind javascript

    • @gunahawk6893
      @gunahawk6893 2 роки тому

      @@NK-fe3md thats cool tho

  • @thesouthsidedev1812
    @thesouthsidedev1812 2 роки тому +13

    Thanks man for this. Just finished watching all your videos on the blind 75 list, I've learnt a lot.

  • @akhileshsonkar2061
    @akhileshsonkar2061 3 роки тому +20

    Thanks for Explanation.....this code will work in Java but not worked same in C++ with negative number 🙃For C++ code--------
    int getSum(int a, int b) {
    while(b!=0)
    {
    unsigned int temp=(a&b);
    a=a^b;
    b=(int)(temp

  • @siomarapantarotto
    @siomarapantarotto 2 роки тому +4

    Thanks so much! You were the only one capable to clear in my mind these bitwise operations handled together. The use of the variable 'tmp', explaining its reason and its location on the code really clarified everything. Congrats for this awesome tutorial. God bless you. 🥰

  • @tsunghan_yu
    @tsunghan_yu 3 роки тому +13

    9:31 Thanks for mentioning this. So that's why my python solution doesn't handle negative numbers.

  • @dorondavid4698
    @dorondavid4698 3 роки тому +52

    Lol I like seeing everyone complain about this being Java...People, I'm a C++/C# programmer and I watch his Python videos.
    It's not hard to convert one language to another...the point of these vids is to understand the algorithm and apply it!

    • @meowmaple
      @meowmaple 2 роки тому +9

      Yup its not hard, but as he mentioned you can't implement the algorithm that he show in the video in python.

    • @studyaccount794
      @studyaccount794 2 роки тому +1

      I also code in java but I can easily understand c++/c and not to mention I'm here so I probably understand python too. It's not that difficult after some time you just start understanding them for some unknown reason (a good unknown reason).

    • @rhl_
      @rhl_ 2 роки тому +1

      Try implementing this code in c/c++ then come back .
      people are complaining because he chose the easy way out of this. and didn't wrote the code in c/c++.

    • @dorondavid4698
      @dorondavid4698 2 роки тому +2

      @@rhl_ What lol
      C++ was MADE for bit-shifting
      Do you even know how C++ works?

    • @rhl_
      @rhl_ 2 роки тому +1

      @@dorondavid4698 ayyo never said cpp wasn't made for bit masking. Handling -ve number during bit operation is difficult in CPP. If u r so confident in ur coding skills , convert the code to CPP and run it for -ve number 👀.

  • @msris108
    @msris108 2 роки тому +11

    Hey man love your videos, your explanation is absolutely spot on: the default int val in python is too big.
    For people crying about python, mask to limit int size to 32bit (0xffffffff). Don't spread hate people :) cheers
    class Solution:
    def getSum(self, a: int, b: int) -> int:
    mask=0xffffffff
    while b & mask:
    a, b = (a ^ b), (a & b) 0 else a

    • @mirrorinfinite5392
      @mirrorinfinite5392 2 роки тому +1

      hi! in what case will b be more than 0 for your return statement? dont really get the return statement and would appreciate if you could explain!

    • @freyappari
      @freyappari 3 місяці тому

      real G ,thanks man

    • @srivathsansundar2061
      @srivathsansundar2061 3 місяці тому

      Realy appreciate the explanation, and keep continuing the great work, thank you good sir!

  • @osasikemwenogieva6998
    @osasikemwenogieva6998 2 роки тому +5

    return Integer.sum(a,b); also works in a pinch! Java

  • @kilyos9212
    @kilyos9212 3 роки тому +13

    I prefer the Java because it’s more similar to other languages. Either way thanks for this great video

  • @mrmcyx8283
    @mrmcyx8283 2 роки тому +6

    This is fantastic. Now I can save the world without using any "+". ; )

  • @zg5828
    @zg5828 3 роки тому +7

    Umm... I think I found out why Neet used Java. I converted it to Python but I got a time-limit exceed error. I guess Java automatically handles some of the edge cases (like when the input is a negative number ) :/ .

  • @draugno7
    @draugno7 23 дні тому

    Made it! Will continue solving others, though, it became fun :D

  • @hamzamahmood8980
    @hamzamahmood8980 2 роки тому +1

    my solution in python, use log instead of binary:
    def getSum(self, a: int, b: int) -> int:
    # check one is zero and other is positive
    if min(a,b) == 0:
    return max(a,b)
    # if one is zero and other is negative
    if max(a,b) == 0:
    return min(a,b)
    # use property of ln, ln e^x = x
    x = math.e**a
    y = math.e**b
    z = x*y
    return int(math.log(z))

  • @陳涵宇-d4s
    @陳涵宇-d4s Місяць тому

    Just finish blind 75, thanks a lot!

  • @karloninvestors4056
    @karloninvestors4056 3 роки тому +10

    Please continue with python

  • @codelateral675
    @codelateral675 Рік тому +2

    Use whatever language you want we will still be here. Actually, I am a Java programmer. I didn't even know p of python but Neetcode is the only channel I watch for coding concepts. Most people don't understand programming languages are not important the purpose here is to understand the concept behind the questions. If you understand the concept you should be good enough to code it yourself if not then you don't know that programming language well enough. OMG, I want to write 2 pages regarding this but I think wise people will understand this.

  • @SatyaMantha
    @SatyaMantha Рік тому

    I code in java. But I first come to Neetcode, listen to your explanation, go back and code in Java. My fav youtuber !

  • @Eggleweb97
    @Eggleweb97 2 роки тому

    class Solution:
    def getSum(self, a: int, b: int) -> int:

    return sum([a,b])

  • @GauravSingh-bf7wu
    @GauravSingh-bf7wu 2 роки тому +2

    Great explaination, but it doesn't work in C++. need additional change. See below comment of Akhilesh Sonkar for the solution

  • @ayeshaadhikari6123
    @ayeshaadhikari6123 2 роки тому +2

    Thank you so much for such a clear explanation! Very helpful!

  • @akshaymonga
    @akshaymonga 2 роки тому +1

    man, your explanations are the best out there in youtube.

  • @stith_pragya
    @stith_pragya 10 місяців тому +1

    Thank You So Much for this wonderful video.........🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻

  • @jaslinkaur645
    @jaslinkaur645 2 роки тому +10

    can you explain why Python is not ideal for solving this binary question? Loved your logical approach and explanation in this video

    • @eyyo3571
      @eyyo3571 2 роки тому +2

      I tried implementing the same method in python. Doesnt work for -ve numbers. The guy explain it at 9:31

    • @prabinlamsal74
      @prabinlamsal74 Рік тому

      Yeah, his logical approach rather than an emotional approach is quite good . lol.

  • @narendrakumariitb
    @narendrakumariitb 2 роки тому

    this is more than hard question and you have explained it in more than easy way . thanks

  • @crazyboy-gw7rk
    @crazyboy-gw7rk Рік тому

    your are one of best teacher out there

  • @jackieli1724
    @jackieli1724 Рік тому

    Thank you really! Your course is the best of all😃

  • @TheLustz
    @TheLustz 2 роки тому

    whats funny is that before he made the temp variable, the code subtracts b from a
    like this:
    def getSum(a, b):
    while b != 0:
    a = a^b
    b = (a&b)

  • @johns3641
    @johns3641 3 роки тому +7

    @NeetCode, can you please post the python solution? I tried converting your C solution to python but got a time limit exceeded error :(

    • @ssshukla26
      @ssshukla26 3 роки тому +1

      There was a good reason to do this solution in java...

    • @katearcher8881
      @katearcher8881 2 роки тому +5

      def getSum(self, a: int, b: int) -> int:
      mask = 0xFFFFFFFF
      while b != 0:
      tmp = (a & b)

    • @johns3641
      @johns3641 2 роки тому

      @@katearcher8881 Thanks!!

    • @johns3641
      @johns3641 2 роки тому +1

      @@katearcher8881 Thanks! Never would've guessed this. Wow.

  • @madhurjajoo9404
    @madhurjajoo9404 3 роки тому +5

    You actually listened and coded in java🥺 Thanks man. Also I see so many requests to stick to python I hope you do what you feel right I am okay with any of the language because your explanation does the work for me💯

    • @zr60
      @zr60 2 роки тому +5

      He used Java because it's difficult to solve in Python LOL

  • @U2011-n7w
    @U2011-n7w 5 місяців тому +1

    best explanation

  • @sdaiwepm
    @sdaiwepm Рік тому +1

    OR we could use logs: return int(log((e**a)*(e**b)))

  • @anahitahassan9687
    @anahitahassan9687 2 роки тому +1

    How come if I use this solution in Python I get a Time Limit Exceeded error but it runs just fine with Java?

  • @serioussam2071
    @serioussam2071 3 місяці тому

    Coming back to your roots that is Java😊

  • @UKMatt32
    @UKMatt32 2 роки тому

    Is it cheeky to just create list = [a, b] and then return sum(list)? (It worked as a solution)

  • @daekunhan
    @daekunhan 2 роки тому

    The best explanation EVER!

  • @terrancewang7329
    @terrancewang7329 3 роки тому +32

    Please please please stick with Python...Absolutely the most interview-friendly language!!!

  • @eyyo3571
    @eyyo3571 2 роки тому

    Is the microsoft logo at the beginning just random? Or is this problem tagged for microsoft?

  • @ahmetturancanpolat1743
    @ahmetturancanpolat1743 2 роки тому

    Thank man I read your code easily, I dont have a problem with java, but do you have a solution in python for negative numbers?

  • @akka9335
    @akka9335 2 роки тому

    Coding in Java after coding in python for many days is too frustrating!!! So many semi-colon mistakes! Such a long method call for just print(debug purposes)..Kindly provide an alternative solution in Python too.

  • @LamNguyen-nm1id
    @LamNguyen-nm1id 2 роки тому

    for what it's worth, the problem itself should be hard, not because it's harder than the actual hard problem, but it's not medium either

  • @parthshukla6189
    @parthshukla6189 3 роки тому +16

    Please use Python man 🥺
    My career is literally dependent on your channel

    • @AnarchySane
      @AnarchySane 3 роки тому

      Shiiiit)

    • @ShivamJha00
      @ShivamJha00 3 роки тому +4

      Pretty bad career you got there if it's "dependent" on a rando youtube channel

    • @parthshukla6189
      @parthshukla6189 3 роки тому +3

      I guess its a good thing to find a instructor from which you understand things the best amount

    • @shrimpo6416
      @shrimpo6416 2 роки тому

      You are NOT alone! I am pretty dependent on his channel too!!! I am a college student majoring at Stat with ZERO cs background so his videos means everything to me. Plus, I code in python only.

  • @UECAshutoshKumar
    @UECAshutoshKumar Рік тому +1

    Thank you

  • @biswaMastAadmi
    @biswaMastAadmi 2 роки тому

    Beautiful explanation

  • @satyamgupta6030
    @satyamgupta6030 Рік тому

    thanks neetcode

  • @cuteangel1726
    @cuteangel1726 2 роки тому

    Have you done division of two integers

  • @ShivangiSingh-wc3gk
    @ShivangiSingh-wc3gk 2 роки тому

    Nice, I was making the 1and 1 case too complicated

  • @kalashnikov203
    @kalashnikov203 2 роки тому

    Doesn't work for negative integers, since left shift operator on negative integers is not standardized and would give different answers based on compiler.

  • @ayushsrivastava3243
    @ayushsrivastava3243 2 роки тому

    Wow! such an awesome explanation

  • @Isha_Sethi
    @Isha_Sethi Рік тому

    Helpful, thank you!

  • @koushik_kuruva
    @koushik_kuruva Рік тому

    excellent explaination

  • @ilanaizelman3993
    @ilanaizelman3993 3 роки тому +1

    Thanks a lot!

  • @sharemarketsher6073
    @sharemarketsher6073 3 роки тому +6

    Brother please just use python

  • @namoan1216
    @namoan1216 2 роки тому +1

    why python give time limit exceeded?

  • @firezdog
    @firezdog 2 роки тому

    Why is this problem on Blind 75? How does knowing how to solve it help solve other questions?

    • @gunahawk6893
      @gunahawk6893 2 роки тому

      If you need to work with bit or low level things this would be helpful

    • @nikhil_a01
      @nikhil_a01 Рік тому +1

      LeetCode's official solution says that this is a popular question at Facebook and the creator of the Blind 75 list was a Facebook tech lead. That's probably one reason why it's on the list.
      It's also a tricky bit manipulation problem so it can help solidify your skills there. Since it's an annoying problem it's better to do it now than see it for the time in an interview.

  • @bubbletea8793
    @bubbletea8793 2 роки тому

    Thanks man pt. 1

  • @jessica_1811
    @jessica_1811 Рік тому

    I ignored the "dislike" when you said so. But when I actually started doing this question i really disliked it.

  • @Andrew-pj9kb
    @Andrew-pj9kb 4 місяці тому

    I am completely skipping all bit manipulation questions.
    If an interviewer expects me to know this, they can get bleeped.

  • @No-yp1uv
    @No-yp1uv 11 місяців тому

    why is the time complexity O(1)

  • @HotDiceMiniatures
    @HotDiceMiniatures 3 роки тому

    Use Java if you want to baby! From the perspective of a beginner, the fact that this is done without an if structure is mind blasting.

  • @nehaa3778
    @nehaa3778 2 роки тому

    Finally a Java vid from you. Thanks for the vid though the time complexity can't be just O(1) right?

  • @owenwu7995
    @owenwu7995 Рік тому

    python solution:
    return(add(a, b))
    I feel like this is too easy though even though this was accepted

  • @gigachadkartik
    @gigachadkartik 2 роки тому +1

    Doesn't work for c and c++

  • @MaxFung
    @MaxFung 8 місяців тому

    screw this. I just used the += operator in Python and said if someone wants to ask me a bitwise question in an interview I might as well just give up

  • @ravinders9221
    @ravinders9221 2 роки тому

    nice & Thank you!!

  • @pranavsharma7479
    @pranavsharma7479 2 роки тому

    this is the problem which you need to learn

  • @namoan1216
    @namoan1216 2 роки тому

    this problem is crazy

  • @zr60
    @zr60 2 роки тому

    doesn't work for all test cases on python

  • @alonebeast5310
    @alonebeast5310 2 роки тому

    thanks buddy

  • @bhushanlaware
    @bhushanlaware 2 роки тому

    This code is faster than sum operator. Then why not to just use this for sum instead?

  • @DzwiekiOtchlani
    @DzwiekiOtchlani Рік тому

    How the hell this is marked as a medium? It’s easier than most of the “easy” ones that I’ve seen

  • @harshvardhanranvirsingh9473
    @harshvardhanranvirsingh9473 3 роки тому +10

    Please! I'm solely here for a python

  • @NK-fe3md
    @NK-fe3md 2 роки тому

    Can someone please explain why I can't use sum to solve this?
    class Solution:
    def missingNumber(self, nums: List[int]) -> int:
    #is 0 missing ?
    zero_missing = 0 in nums
    if not zero_missing:
    return 0
    tot_sum = 0
    for i in range(len(nums) + 1):
    tot_sum += i
    arr_sum = sum(nums)
    return tot_sum - arr_sum

  • @KeshavKumar69420
    @KeshavKumar69420 3 роки тому +13

    Please remain in Python !!!!!🙏

  • @sauravchandra10
    @sauravchandra10 Рік тому

    It does not work for -1 and 1

  • @NoName-ef2gv
    @NoName-ef2gv 3 роки тому +1

    Lol you’ve thumbed down this question too and asked us to not pay attention to it

  • @kobebyrant9483
    @kobebyrant9483 Рік тому

    really nicely explained!

  • @jbn999
    @jbn999 2 роки тому +2

    If there are only two elements... append them into a list and do a sum on that list - Python Solution.

  • @programming1734
    @programming1734 3 роки тому +1

    Bro no. Don't give up on us so soon :(

  • @AnnieBox
    @AnnieBox 3 роки тому +2

    congrats on the complete 75 list!!! But as a python die-heart fan~~ you bend your knees on this one? No~~ I can't accept this!!! [○・`Д´・ ○]

  • @MrTacoMan123
    @MrTacoMan123 2 роки тому

    lol'd when I saw the dislike. I also did the same for that question

  • @allandogreat
    @allandogreat 2 роки тому

    You used to use Python

  • @narendrakumariitb
    @narendrakumariitb 2 роки тому

    few extra likes for coding in my goto language 😅

  • @easyvedicmaths886
    @easyvedicmaths886 5 місяців тому

    why u did b != 0, can we not do a != 0?

  • @sase1017
    @sase1017 2 місяці тому

    but dont' know why you swtiched to java for this question, but can't say your python solution is good

  • @AndresC96
    @AndresC96 5 місяців тому

    I love you

  • @chanman1568
    @chanman1568 2 роки тому

    return a+b

  • @benalfred42
    @benalfred42 3 роки тому +1

    Keep mixing it with Java!

  • @cmdv42
    @cmdv42 3 роки тому

    💯

  • @kipa_chu
    @kipa_chu 3 роки тому +4

    People crying for python are going to be bad developers. It should be easy as f to port the solution in any language of your choice. I don't even understand python and I've been porting all solutions to C++ from this channel.

    • @gunahawk6893
      @gunahawk6893 2 роки тому

      People complain because they can't move to another language just for one problem

    • @gunahawk6893
      @gunahawk6893 2 роки тому

      Also if u convert this solution to python it would give tle

    • @nikhil_a01
      @nikhil_a01 Рік тому

      Normally I might agree with you but believe it or not sometimes the language does make a difference. This problem is quite a bit trickier in Python because integers have unlimited bit precision. It's not a simple port. To get the two's complement representation of a negative number you normally want to know how many bits your integer is.

  • @qwertythefish6442
    @qwertythefish6442 Рік тому

    Love your dislike to the question

  • @erikm9768
    @erikm9768 2 роки тому

    why java :[

  • @nawendusingh2858
    @nawendusingh2858 Рік тому

    did yo u just use java coz you don't want to explain mask?

  • @无聊的一生
    @无聊的一生 2 роки тому +2

    lol neatcode disliked this questino

  • @СеваБакутов
    @СеваБакутов 10 місяців тому

    +=

  • @claim2game606
    @claim2game606 6 місяців тому

    just look at this overly complicated code in c++ by me.... just rubbish but it works perfectly fine in the constraints defined for a and b ...............................next line
    int getSum(int a, int b) {
    int ans = 0;
    int value = 1;
    if(a < 0 && b < 0) {
    a = abs(a);
    b = abs(b);
    value = -1;
    }
    if(a < 0 || b < 0) {

    if(a < 0) {
    if(abs(a) > b) {
    value = -1;
    }
    else {
    int t = b;
    b = a;
    a = t;
    }
    }
    else {
    if(abs(b) > a) {
    value = -1;
    int t = b;
    b = a;
    a = t;
    }
    }
    a = abs(a);
    b = abs(b);
    int c;
    int d;
    int i = 0;
    int e = 0;
    while(a != 0 || b != 0) {
    c = a&1;
    a >>= 1;
    d = b&1;
    b >>= 1;
    if(c + e - d == 0) {
    ans += 0;
    e = 0;
    }
    else if(c + e - d == 1) {
    ans += pow(2, i);
    }
    else if(c + e - d == -1) {
    ans += pow(2, i);
    e = -1;
    }
    i++;
    }
    }

    else {
    int c;
    int d;
    int e = 0;
    int i = 0;
    while(a != 0 || b != 0) {
    c = a&1;
    a >>= 1;
    d = b&1;
    b >>= 1;
    if(c + d + e == 1) {
    ans += pow(2, i);
    e = 0;
    }
    else if(c + d + e == 2) {
    if(a == 0 && b == 0) {
    ans += pow(2, i+1);
    }
    e = 1;
    }
    else if(c + d + e == 3) {
    if(a == 0 && b == 0) {
    ans += pow(2, i);
    ans += pow(2, i+1);
    }
    else {
    e = 1;
    ans += pow(2, i);
    }
    }
    i++;
    }
    }
    return ans*value;
    }

  • @symbol767
    @symbol767 2 роки тому +1

    This problem is stupid af

  • @linshengred
    @linshengred 10 місяців тому

    lol, dislike +1