Hello Folks! This note will help you guys to get started with Online Competitive Coding. This guide is all about the usage of some common tricks and algorithms that can help a lot with competitive coding.

Let's straight forwardly get to the online coding.

1. Mathematics

2. Basic knowledge or atleast a brief background of different concepts related to the languages.

So, as per my personal experience I am here to shortlist my very own views and ideas. How one should get started with all such coding stuffs? How much efficient it would be!.

Let us share a look at some of the following coding paradigms that will come in handy...

Magic no.

You must have seen some coding questions where you're asked to "sum the digits" until it is less than 10. One approach is to just add the digits and if it's less than 10 then print otherwise repeat. Cool!!! Now, try not to fall on this traditional option rather challenge your mathematically skilled minds and think of one of the coolest operator calledmodulo "%".***DRUM BEATS Please***The logic is very simple. DoNumber%9and voila ! you get your answer in one line. Make sure if the result is 0 then pre-check if the number is 0 or multiple of 9. If multiple of 9 then the result is 9 else 0.

Power of 2

You must have come across the situation where you already know that the solution will consist of a number which is nothing but the nth power of 2or you have some affairs related to power of 2. So what's the best method to go for? Hope you want to know the result in O(1) time. Cool,isn't it!?!?!? Ok! So, again pull up your sleeves roll back to your mathematical mind and think of one of the coolest operator i.e., AND "&".***DRUM BEATS Please***The logic is simple. DoNumber&(Number-1)and voila ! you get your answer in one line. If the the result is equal to 0, then the given number is nth power of 2 or else it is not. As simple as that! Example, Number=32. Then 32&(32-1) gives you 0. And henceforth, it's the nth power of 2. Another thing is if you want to know the value of 'n' in nth power of 2. I mean for what n , the 2^n is equal to Number. Again...,***DRUM BEATS Please***The logic is again very simple. DoLog(Number)/Log(2)and voila ! you get your answer in one single line. Example, Number=32 Then Log(32)/Log(2) gives you 5, which is actually 'n' i.e., nth power of 2.

Summary

Modulo 9 Unlocked

Another use of **&** operator is seen

Nth Power of 2 Unlocked

⇮
⇩