PROBLEM LINK:
Author: Manish Pathak
Tester: Manish Pathak
Editorialist: Manish Pathak
DIFFICULTY:
Cakewalk
PROBLEM:
In a bungalow a person found a dead body and informed the police to investigate the matter. Police thought that it would be better to give this case to CBI.CBI team came and found a code. To decode that they want a specialized person,Chef is a right person for this work but he is busy these days so you have to do this job.
Your task is to count the number of digit one in all non-negative integers less than or equal to N .
EXPLANATION:
Brute force approach to do this problem is to calculate the number of 1’s in each and every number <=N.As the testcases were weak so this will work.
AUTHOR’S AND EDITORIALIST’S SOLUTIONS:
Author’s and editorialist’s solution can be found here