Skip to content

Commit

Permalink
Create countOfDigitsInaNumber.cpp
Browse files Browse the repository at this point in the history
Given an integral number N. The task is to find the count of digits present in this number within O(1) time complexity.
  • Loading branch information
24sristi authored Oct 24, 2020
1 parent dc14603 commit 90a0ad6
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions countOfDigitsInaNumber.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <iostream>
#include<cmath>
using namespace std;
int main() {
int n;
cin>>n;
int k = log10(n)+1;
cout<<k;
}
//following method only requires O(1) time complexity

0 comments on commit 90a0ad6

Please sign in to comment.