## MAQ Interview Question for Java Developers

• 0

Country: India
Interview Type: Written Test

Comment hidden because of low score. Click to expand.
1
of 1 vote

2100010006

Comment hidden because of low score. Click to expand.
0

Ans: 1000000000

Comment hidden because of low score. Click to expand.
1
of 1 vote

... well then 2100010006

Comment hidden because of low score. Click to expand.
0
of 0 vote

you have 8th digit as 0, but in your 10 digit number 8 is occurring once.

Comment hidden because of low score. Click to expand.
0
of 0 vote

plzz explain

Comment hidden because of low score. Click to expand.
0
of 0 vote

algos - u have used 9 zeroes so your last or tenth digit should be 8 as in that case only 8 zeroes will left

grumpycat you have used 7 zeroes so your last digit should be 7

Guys please before posting anything think first, posting your comments without thinking is of no use........

Comment hidden because of low score. Click to expand.
0
of 0 vote

The 1st digit describes the no. occurence of 1 - this is 2
The 2nd - no. of occurence of 2 - this is 1.
From 3 to 9 - no occurences
And the last digit is just 1.

Comment hidden because of low score. Click to expand.
0
of 0 vote

ThereĀ“s no info about zeros in your question.

Comment hidden because of low score. Click to expand.
0
of 0 vote

0123456789 (index)
6210001000 ->

Comment hidden because of low score. Click to expand.
0

can u tell me ur approach ?

Comment hidden because of low score. Click to expand.
0
of 0 vote

incomplete question. how about the 10th digit ?? should it describe the number of occurrences of the number 10 ?? or 0 ?? ... stupid

Comment hidden because of low score. Click to expand.
0

9876543210

a number can have 3 0's... duh

Comment hidden because of low score. Click to expand.
0

question was written poorly

Comment hidden because of low score. Click to expand.
0

Hey bro..10 is not a digit, its a number.So, obvious 10th digit will be 0 as digits are
{0,1,2,3,4,5,6,7,8,9} and we have to use digits to form the number.Thus only one possible no. will be 2100010006

Comment hidden because of low score. Click to expand.
0
of 0 vote

9000000000
first digit represent no.of zeros and so on...

Comment hidden because of low score. Click to expand.
0
of 0 vote

0000010006

Comment hidden because of low score. Click to expand.
0
of 0 vote

I took it as this:
13432 => 12110
number has:
1 '4'
2 '3'
1 '2'
1 '1'
0 '0'

``````public static int totalDigitNumber(int n)
{
System.out.print(n);
//get lowest sig fig, incrament place, and divid by 10. loop till 0.
boolean isNegative = false;
if(n<0)
{
isNegative = true;
n*=-1;
}
int totalDigit = 0;
for(; n>0; n/=10)
{
int lsd = n%10;
totalDigit+=Math.pow(10,lsd);
}
if(isNegative)
totalDigit*=-1;
System.out.println(" => " + totalDigit);

}``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

2100010006

Comment hidden because of low score. Click to expand.
0
of 0 vote

{cannot be formed: because it may lead to infinite loop with repeating (10 digit) number. I n the code below I considered array of size 10 instead of 10 digit number}
void generate(){
int a[]={9,0,0,0,0,0,0,0,0,0};
int k=0;
while(true)
{
int b[]={0,0,0,0,0,0,0,0,0,0};
for(int i=0;i<10;i++)
{
// System.out.println(a[i]+"---"+b[a[i]]);

b[a[i]]=b[a[i]]+1;
}
for(int i=0;i<10;i++)
{
a[i]=b[i];

System.out.print(a[i]+" ");
}
System.out.println();
k++;
}
}

Comment hidden because of low score. Click to expand.
0
of 0 vote

0010000017.....(9876543210 index)

Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<stdio.h>

void toarray(int *p, unsigned long i);
int main(){
unsigned long i;
int a[9];
int count;

for(i = 100000000; i <= 999999999; i++){
int k;
toarray(a, i);
for(k = 0; k < 9; k++){
int j;
count = 0;
for(j = 0; j < 9; j++){
if((k + 1)%9 == a[j]){
count++;
}
}
if(count != a[k]){
break;
}
}
if(k == 9 && count == a[k-1]){
printf("%lu\n", i);
}
}
}

void toarray(int *p, unsigned long i){
int j;
int k = 10;
for(j = 8; j >= 0; j--){
p[j] = i % k;
i = i / k;
}
}
ans : 210010005

Checked it for 4 - 9 digit numbers .. above code is for a 9 digit number .
ps: it is a brute force method.

Comment hidden because of low score. Click to expand.
-1
of 1 vote

1000000008

Comment hidden because of low score. Click to expand.
-1
of 1 vote

2100000001

Comment hidden because of low score. Click to expand.
-1
of 1 vote

1111111111

Comment hidden because of low score. Click to expand.
-1
of 1 vote

1111111111

Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

### Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

### Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.