Блог пользователя pratyush_004

Автор pratyush_004, история, 5 месяцев назад, По-английски

I have been practicing for a very long time but always get stuck in XOR,OR,AND related questions and I dont have a good set of problems to practice my bit manipulation skills please provide some good problem set or a sheet to practice bit related questions which have an editorial also in case i get stuck .

Thank You.

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
5 месяцев назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

Colin Galen YT A very good resource. It helped me very much.

»
5 месяцев назад, # |
  Проголосовать: нравится +7 Проголосовать: не нравится

You gotta master it bit by bit.

»
5 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

in bit manipulation question where there is an operation happening like xor or and etc first step is genrally to convert all given integers in an array to their binary format.(Sorry if it is obvious) After that only practice will help.

  • »
    »
    5 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    yea I got this idea now usually people take an array of size 31 and do the operations and check for any observations in all the given numbers.Thanks for pointing out will surely keep in my mind next time.

»
5 месяцев назад, # |
Rev. 2   Проголосовать: нравится +2 Проголосовать: не нравится

What a stupid question. First you have to understand what you need to do to solve the problem then think about how to do it. It seems that you want to practice simply the bitwise operations but if you don't understand what they're used for it's useless.

Solve the problems without using bit manipulation. For practice you can simply use binary strings instead of ints and do the manipulation on the strings. After you understand the concepts behind the solutions, you can add bitwise operations back into the solution.

  • »
    »
    4 месяца назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    do you have a yt channel?

  • »
    »
    4 месяца назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    What if the question involves doing something on bits to get the required answer, like this one: https://codeforces.net/contest/1991/problem/B. Can we do these types of problems without manipulating the bits? (Just asking for guidance since i too faces problems while solving these questions)

    • »
      »
      »
      4 месяца назад, # ^ |
      Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

      no this is also a typical bit manipulation question I posted this blog around a month ago and since then have practised many bit questions so now i am confident in them.

      In this question you just had to see that by taking the OR of all the numbers in the array with their adjacent element we can place them in the new array and AND them together to get the desired result its observation+practice.You can check my code here 273780952

»
5 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Most of the bit manipulation problems are not bit related rather string/array of bits(0/1) related problems. Try to convert them to binary array/string, then redefine the problem statement to solve.

»
4 месяца назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

be my student.