Computer Science, asked by suman1873, 8 months ago

Find Password:
Detective Buckshee Junior has been approached by the shantiniketan kids society for help
in finding the password to the games complex. After hearing the scenario, detective
Buckshee Junior realises that he will need a programmer's support. He contacts you and
requests your help. Please help the detective by writing a function to generate the
password.
The scenario is as below -
Five numbers are available with the kids.
These numbers are either stable or unstable.
A number is stable if each of its digit occur the same number of times, i.e. the frequency of
each digit in the number is the same. For e.g. 2277, 4004, 11, 23, 583835, 1010 are
examples of stable numbers.
Similarly, A number is unstable if the frequency of each digit in the number is NOT the
same. For e.g. 221, 4314, 101, 233, 58135, 101 are examples of unstable numbers..
The password can be found as below -
i.e. password = Maximum of all stable numbers + Minimum of all Unstable numbers
Assuming that the five numbers are passed to a function as input1, input2, input3, input4
and inputs, complete the function to find and return the password.
For Example:
If input1 = 12, input2 = 1313, input3 = 122, input4 = 678, and input5 = 898,
stable numbers are 12, 1313 and 678
unstable numbers are 122 and 898
So, the password should be = Maximum of all stable numbers + Minimum of all
Unstable numbers = 1313 + 122 = 1435
ONLY JAVA METHOD​

Answers

Answered by rock2604
10

Answer:

1435122

Explanation:

Answered by ravilaccs
1

Answer:

The program is given below

Explanation:

Given: Detective Buckshee Junior has been approached by the Shantiniketan kids society for help in finding the password to the game's complex. After hearing the scenario, detective Buckshee Junior realizes that he will need a programmer's support. He contacts you and requests your help. Please help the detective by writing a function to generate the

password.

To find:  Program

Solution:

import java.io.*;

import java.util.*;

class fiir

{

public static void main(String ar[])

{

Scanner sc=new Scanner(System.in);

int n=sc.nextInt();

int sum=0;

int inp[]=new int[n];

for(int m=0;m<n;m++)

{

inp[m]=sc.nextInt();

}

int dig[]=new int[10];

int un=0,st=0;

//char c[];

String s=" ";

String sstr="";

String ustr="";

TreeSet<Integer> tr=new TreeSet<Integer>();

for(int i=0;i<inp.length;i++)

{

s=String.valueOf(inp[i]);

char c[]=s.toCharArray();

int narr[]=new int[c.length];

for(int j=0;j<c.length;j++)

{

narr[j]=Integer.parseInt(String.valueOf(c[j]));

}

for( int k=0;k<narr.length;k++)

{

dig[narr[k]]=(dig[narr[k]])+1;

}

for(int p=0;p<10;p++)

{

if(dig[p]!=0)

{

tr.add(dig[p]);

}

}

if(tr.size()>1)

{

un=un+1;

ustr+=s+" ";

}

else

{

st=st+1;

sstr+=s+" ";

}

for(int o=0;o<10;o++)

{

dig[o]=0;

}

tr.clear();

}

String uarray[]=ustr.split(" ");

int unum[]=new int[uarray.length];

for( int t=0;t<uarray.length;t++)

{

Integer.parseInt(String.valueOf(uarray[t]));

unum[t]=Integer.parseInt(String.valueOf(uarray[t]));

sum=sum+unum[t];

}

System.out.println(sum);

}

}

Similar questions