## Adobe Interview Question for Member Technical Staffs

• 0

Country: India
Interview Type: In-Person

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

Take the sum and check for divisiblity by 3.

So maintain running sum (mod 3, to cater to overflows) and check if sum is 0 when stream ends.

It does not matter whether you get the most significant digit first.

This assumes base 10.

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

yes you are right. digits sum of a number divisible by 3 is always divisible by 3.
Good to know. Thanks.

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

Added in which direction? in front or back?

1 <- 2 <- 3 = 123?

or

3 -> 2 -> 1 = 321?

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

Does not matter. See other answer.

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

``````void multiple0f3()
{
int previousmod=0;
int curmod=0;
char ch;
bool test[100]; //Assuming max of 100 digits
int k=0;
cin>>ch;
while(ch!='e')
{
int d=ch-'0';
curmod=d%3;
previousmod=(curmod+previousmod)%3;
if(previousmod==0)
test[k++]=true;
else
test[k++]=false;
cin>>ch;
}
cout<<endl;
for(int i=0;i<k;i++)
cout<<test[i]<<endl;
}``````

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

(digit1+digit2+digit3)%3 should be equal to zero.

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

Umm.... 4231.

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

as the numbers are coming in, we can keep doing processing on these numbers by adding as the number comes and % the sum with 3, so the resultant output will be 0,1,2 we add this output with the next number coming in the stream and again % the sum by 3.

But this has the disadvantage of operating all the times even when not asked/required.

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

import java.util.Scanner;

public class divby3 {
public static void main (String args[])
{
int sum=0;
int i = 1;
while (i==1)
{
Scanner in =new Scanner(System.in);
String digit=in.next();
int number=Integer.parseInt(digit);
sum=sum+number;
System.out.println(sum);
if (sum%3==0)
{
System.out.println("Divisible by 3");
}
else
{
System.out.println("Not divisibe by 3");
}
System.out.print("You want to continue?");
String response=in.next();
i=Integer.parseInt(response);
}
}
}

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

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Mod3
{
class Program
{
static void Main(string[] args)
{
int[] arr=new int[10];
int i,sum=0;
char ch='y';

for(i=0;i<10;i++)
{
Console.WriteLine("Enter the digit");
sum = sum + arr[i];
Console.WriteLine(sum);
Console.WriteLine("Do you want to continue (Y/N) :");
switch (ch)
{
case 'y':
case 'Y':
continue;
case 'n':
case 'N':

if (sum % 3 == 0)
{
Console.WriteLine("Divisble by 3");
break;
}
else
{
Console.WriteLine("Not divisible by 3");
break;
}

default:
Console.WriteLine("Enter the correct value");
break;
}

}

}
}
}

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

``````package test;
import java.io.DataInputStream;
import java.io.IOException;
public class MultipleOf3 {
public static void main(String [] args)
{
int in;
DataInputStream br=new DataInputStream(System.in);
try {
int sum=0;
{
Character c=(char)in;
int i = 0;
if(c<='9'&&c>='0')
{
i=Integer.parseInt(c.toString());
sum+=i;
System.out.print(i);
if(sum%3==0)
{
break;
}
}
}
System.out.println();
System.out.println("div by 3!!!");
} catch (IOException e) {
e.printStackTrace();
}
}
}``````

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.