`{"id":"a5347310-0277-4672-b409-d16cea413bf3","name":"Digit Frequency","description":"<p><span style=\"color: rgb(14, 16, 26);\">1. Each digit (0 to 9) denotes the student of the Optica Student community.</span></p><p><span style=\"color: rgb(14, 16, 26);\">2. You are given a number n where ith digit denotes that ith task that is assigned to the corresponding digit student.</span></p><p><span style=\"color: rgb(14, 16, 26);\">2. You are given a digit d denotes a student.</span></p><p><span style=\"color: rgb(14, 16, 26);\">3. You are required to calculate the frequency of digit d in number n or how many tasks are assigned to student d.</span></p><p><br></p><p><br></p>","inputFormat":"<p>A number n A digit d</p>","outputFormat":"<p>A number representing frequency of digit d in number n</p>","constraints":"<p>0 &lt;= n &lt;= 10^9 0 &lt;= d &lt;= 9</p>","sampleCode":{"cpp":{"code":"#include<iostream>\nusing namespace std;\nint digFreq(int n, int d) {\n //write your code here\n}\nint main() {\n int n, d;\n cin >> n >> d;\n int res = digFreq(n, d);\n cout << res << endl;\n}"},"java":{"code":"import java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static void main(String[] args) {\r\n Scanner scn = new Scanner(System.in);\r\n int n = scn.nextInt();\r\n int d = scn.nextInt();\r\n int f = getDigitFrequency(n, d);\r\n System.out.println(f);\r\n }\r\n\r\n public static int getDigitFrequency(int n, int d) {\r\n // write code here\r\n }\r\n}"},"python":{"code":"n = int(input())\nd = int(input())\n\ndef freq(n,d):\n #write your code here\nif __name__ == \"__main__\": \n print(freq(n,d))"}},"points":10,"difficulty":"easy","sampleInput":"994543234\r\n 4","sampleOutput":"3","questionVideo":"https://www.youtube.com/embed/TJvWrEMuO5k","hints":[],"associated":[{"id":"58c6fd15-41f7-4580-8f4f-ed77f13ef9b6","name":"(Digit Freq) How are elements in an array accessed?","slug":"digit-freq-how-are-elements-in-an-array-accessed","type":4},{"id":"72dfa0ed-7dd7-4fa4-b9ad-ef8515341d90","name":"(Digit freq) Assuming int is of 4bytes, what is the size of int arr;?","slug":"digit-freq-assuming-int-is-of-4bytes-what-is-the-size-of-int-arr-15","type":4},{"id":"7dd42670-88cb-4f0d-bf47-b3c04ed7afe6","name":"(Digit Freq) How do you instantiate an array in Java?","slug":"digit-freq-how-do-you-instantiate-an-array-in-java","type":4},{"id":"f6017416-88ed-49f0-991e-7cbce3ef6816","name":"(Digit freq) Which of these best describes an array?","slug":"digit-freq-which-of-these-best-describes-an-array","type":4}],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"f10b54f1-0f44-408f-82d5-89c189f4ad57","name":"Function and Arrays","slug":"function-and-arrays","type":0},{"id":"2c89b020-5477-4f35-ba0f-168c183947f9","name":"Digit Frequency","slug":"digit-frequency","type":1}],"next":{"id":"d86632a7-19b7-4434-a8e1-d0b5d0be6b92","name":"Digit Frequency","type":3,"slug":"digit-frequency"},"prev":{"id":"333c874a-cde7-4779-869a-904e1d56eee0","name":"Introduction To Functions","type":0,"slug":"introduction-to-functions"}}}`

# Digit Frequency

<p><span style="color: rgb(14, 16, 26);">1. Each digit (0 to 9) denotes the student of the Optica Student community.</span></p><p><span style="color: rgb(14, 16, 26);">2. You are given a number n where ith digit denotes that ith task that is assigned to the corresponding digit student.</span></p><p><span style="color: rgb(14, 16, 26);">2. You are given a digit d denotes a student.</span></p><p><span style="color: rgb(14, 16, 26);">3. You are required to calculate the frequency of digit d in number n or how many tasks are assigned to student d.</span></p><p><br></p><p><br></p>

`{"id":"a5347310-0277-4672-b409-d16cea413bf3","name":"Digit Frequency","description":"<p><span style=\"color: rgb(14, 16, 26);\">1. Each digit (0 to 9) denotes the student of the Optica Student community.</span></p><p><span style=\"color: rgb(14, 16, 26);\">2. You are given a number n where ith digit denotes that ith task that is assigned to the corresponding digit student.</span></p><p><span style=\"color: rgb(14, 16, 26);\">2. You are given a digit d denotes a student.</span></p><p><span style=\"color: rgb(14, 16, 26);\">3. You are required to calculate the frequency of digit d in number n or how many tasks are assigned to student d.</span></p><p><br></p><p><br></p>","inputFormat":"<p>A number n A digit d</p>","outputFormat":"<p>A number representing frequency of digit d in number n</p>","constraints":"<p>0 &lt;= n &lt;= 10^9 0 &lt;= d &lt;= 9</p>","sampleCode":{"cpp":{"code":"#include<iostream>\nusing namespace std;\nint digFreq(int n, int d) {\n //write your code here\n}\nint main() {\n int n, d;\n cin >> n >> d;\n int res = digFreq(n, d);\n cout << res << endl;\n}"},"java":{"code":"import java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static void main(String[] args) {\r\n Scanner scn = new Scanner(System.in);\r\n int n = scn.nextInt();\r\n int d = scn.nextInt();\r\n int f = getDigitFrequency(n, d);\r\n System.out.println(f);\r\n }\r\n\r\n public static int getDigitFrequency(int n, int d) {\r\n // write code here\r\n }\r\n}"},"python":{"code":"n = int(input())\nd = int(input())\n\ndef freq(n,d):\n #write your code here\nif __name__ == \"__main__\": \n print(freq(n,d))"}},"points":10,"difficulty":"easy","sampleInput":"994543234\r\n 4","sampleOutput":"3","questionVideo":"https://www.youtube.com/embed/TJvWrEMuO5k","hints":[],"associated":[{"id":"58c6fd15-41f7-4580-8f4f-ed77f13ef9b6","name":"(Digit Freq) How are elements in an array accessed?","slug":"digit-freq-how-are-elements-in-an-array-accessed","type":4},{"id":"72dfa0ed-7dd7-4fa4-b9ad-ef8515341d90","name":"(Digit freq) Assuming int is of 4bytes, what is the size of int arr;?","slug":"digit-freq-assuming-int-is-of-4bytes-what-is-the-size-of-int-arr-15","type":4},{"id":"7dd42670-88cb-4f0d-bf47-b3c04ed7afe6","name":"(Digit Freq) How do you instantiate an array in Java?","slug":"digit-freq-how-do-you-instantiate-an-array-in-java","type":4},{"id":"f6017416-88ed-49f0-991e-7cbce3ef6816","name":"(Digit freq) Which of these best describes an array?","slug":"digit-freq-which-of-these-best-describes-an-array","type":4}],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"f10b54f1-0f44-408f-82d5-89c189f4ad57","name":"Function and Arrays","slug":"function-and-arrays","type":0},{"id":"2c89b020-5477-4f35-ba0f-168c183947f9","name":"Digit Frequency","slug":"digit-frequency","type":1}],"next":{"id":"d86632a7-19b7-4434-a8e1-d0b5d0be6b92","name":"Digit Frequency","type":3,"slug":"digit-frequency"},"prev":{"id":"333c874a-cde7-4779-869a-904e1d56eee0","name":"Introduction To Functions","type":0,"slug":"introduction-to-functions"}}}` Editor

# Digit Frequency

easy

1. Each digit (0 to 9) denotes the student of the Optica Student community.

2. You are given a number n where ith digit denotes that ith task that is assigned to the corresponding digit student.

2. You are given a digit d denotes a student.

3. You are required to calculate the frequency of digit d in number n or how many tasks are assigned to student d.

## Constraints

0 <= n <= 10^9 0 <= d <= 9

## Format

### Input

A number n A digit d

### Output

A number representing frequency of digit d in number n

## Example

Sample Input

```.css-23h8hz{color:inherit;font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;}994543234 4```

### Sample Output

`.css-3oaykw{color:var(--chakra-colors-active-primary);font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;font-family:Monospace;}3`

Question Video

Discussions

Show Discussion

Related Resources 