Security Key Description A company is transmitting data to another server. The data is in the form of numbers. To secure the data during transmission, they plan to obtain a security key that will be sent along with the data. The security key is identified as the count of the repeating digits in the data. Write an algorithm to find the security key for the data. Input The input consists of an integer data, representing the data to be transmitted. Output Print an integer representing the security key for the given data. If no data is repeated it should display -1 Constraints NA Example Input: 578378923 Output: 3 Explanation The repeated digits in the data are 7, 8 and 3. So, the security key is 3. Public Test Cases # Input Expected Output 1 578378923 3 Programming Language: C (GCC 9.2.0)

Security Key
Description
A company is transmitting data to another server. The data is in the form of numbers. To secure 
the data during transmission, they plan to obtain a security key that will be sent along with the 
data. The security key is identified as the count of the repeating digits in the data.
Write an algorithm to find the security key for the data.
Input
The input consists of an integer data, representing the data to be transmitted.
Output
Print an integer representing the security key for the given data. If no data is repeated it should 
display
-1
Constraints
NA
Example
Input:
578378923
Output: 3
Explanation
The repeated digits in the data are 7, 8 and 3. So, the security key is 3.
Public Test Cases
 
# Input Expected Output
1 578378923 3
 
Programming Language: C (GCC 9.2.0)


#include <stdio.h>
int main()
{
 long int n;
 scanf("%ld", &n);
 int a[10]={0};
 while(n)
 {
 a[n%10]++;
 n=n/10;
 }
 int i,sk=0;
 for(i=0;i<10;i++)
 {
 if(a[i]>1)
 sk++;
 }
 if(sk==0)
 sk=-1;
 printf("%d",sk);



Comments