Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

Is Right Shift faster than Left Shift?

$
0
0

Problem link: https://www.codechef.com/problems/ANDMIN

I made two submissions which does the same thing but in a different way. Basically, I have to check if the bit is set at position i in variable val. I did this in the following two ways:

  • $(1 << i) & val$

  • $(val >> i) & 1$

The first approach is giving TLE but the second one passed.

Submission Link:

Any ideas why does this happen?


Viewing all articles
Browse latest Browse all 39796

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>