
Asked in Paxcom India
Digit Count In Range Problem Statement
Given an integer K
, and two numbers A
and B
, count the occurrences of the digit K
in the range [A, B].
Include both the lower and upper limits in the count.
Input:
The first line contains an integer ‘T’ denoting the number of test cases.
For each test case:
- The first line contains an integer ‘K’, representing the digit to count.
- The second line contains two space-separated integers, ‘A’ and ‘B’, denoting the range.
Output:
For each test case, output a single integer indicating the occurrences of ‘K’ within the range [A, B].
Example:
Input:
K = 3
A = 1
B = 15
Output:
2
Explanation:
In the range [1, 15], the digit 3 appears in 3 and 13, totaling 2 occurrences.
Constraints:
1 <= T <= 100
0 <= K <= 9
0 <= A, B <= 1018
- Time limit: 1 sec

AnswerBot
4mo
Count occurrences of a digit in a given range.
Iterate through the range [A, B] and count occurrences of digit K.
Convert integers to strings for easier digit comparison.
Handle edge cases like when A or...read more
kishore kumar
10mo
student at
Saranathan College of Engineering, Tiruchirapalli
/ * java solution: public static void main(String[] args) { Scanner sc=new Scanner(System.in); int k=sc.nextInt(); int base=10; char init=Character.forDigit(k,base); int a=sc.nextInt(); int b=sc.nextI...read more
Help your peers!
Add answer anonymously...
Top Software Developer Interview Questions Asked at Paxcom India
Q. Character Frequency Problem Statement You are given a string 'S' of length 'N'. ...read more
Q. Find Two Missing Numbers Problem Statement Given an array of unique integers whe...read more
Q. Missing Number Problem Statement You are provided with an array named BINARYNUMS...read more
Interview Questions Asked to Software Developer at Other Companies
Top Skill-Based Questions for Paxcom India Software Developer
Algorithms Interview Questions and Answers
250 Questions
Data Structures Interview Questions and Answers
250 Questions
Web Development Interview Questions and Answers
250 Questions
Java Interview Questions and Answers
250 Questions
SQL Interview Questions and Answers
250 Questions
Software Development Interview Questions and Answers
250 Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

