Counting Bits In a Number – Leetcode

Given an integer n, return an array ans of length n + 1 such that for each i (0 <= i <= n), ans[i] is the number of 1‘s in the binary representation of i. Example 1: Input: n = 2 Output: [0,1,1] Explanation: 0 –> 0 1 –> 1 2 –> 10 Example 2: Input: n = 5 Output: [0,1,1,2,1,2] Explanation: 0 –> 0 1 –> 1 2…

Read more...

Print Digit of Number In Words

Given a number N, Print digits of that number in words. eg, 100 should be written as One Zero Zero Solution [Using Recursion]

Read more...

MyGate Interview Experience. [SET-1]

Round 1 – Written They(MyGate) had printed questions on paper there were multiple sets of those like we used to have in School Exam. Each paper has 3 questions and We need to write working code on laptop and mail to the recruiter. Out of 4 questions – 1 Easy, 1 Medium and 2 hard…

Read more...

String to Integer (atoi)

Implement atoi which converts a string to an integer. The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this character, takes an optional initial plus or minus sign followed by as many numerical digits as possible, and interprets them as a numerical value. The string can contain…

Read more...