Adobe Interview Question for Software Engineer / Developers






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

<pre lang="" line="1" title="CodeMonkey83779" class="run-this">#include <iostream>
using namespace std;

int cal (int num) {
int total = 3;
int model = 100 % num;
int begin = 11;
while ((model + begin) % num != 0) {
begin = (model + begin) % num;
model = (10 * model)%num;
total++;
}
return total;
}

int main() {
int num = 0;
while (num % 10 != 3) {
cout << "input num: ";
cin >> num;
}
int loc = cal(num);
for (int i = 0; i < loc; i++)
cout << 1 ;
cout << endl;
return 0;
}

</pre><pre title="CodeMonkey83779" input="yes">1113</pre>

- Anonymous August 10, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

can you explain the logic behind the program ?

- Anonymous April 06, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

abe chutiye... logic samjha...:P

- Zuckerberg April 25, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

abe Zuckerberg chutiye pehle tu facebook ka logic samjhaa

- Anonymous May 28, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

As only xxx7 times xxx3 gets xxx1, the last digit of the other number is 7. Take this information, and given xxx3, formulate like this: A = 10*X + 3, B = 10*Y + 7. A is the given number, X is known, Y is integer. Now it is good to test from Y = 0 to n, until A*B = 1xxxxx1. O(n).

- xbai@smu.edu August 11, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

This can't work as the final result can be really big. You can't use a number to record the result.

- Anonymous August 12, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

given n , construct a number 'k' with 1's greater than n.
while(true)
{
if k%n == 0, then return k
else k=k*10+1
}

- blueskin August 12, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

This is more efficient solution! You need to check overflow, otherwise, it goes forever.

while(k>0)
{
    if (k%n == 0) 
        return k
    else 
         k=k*10+1
}

- topgun August 13, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
long int d=3;
int j=0,a=1;
while(j<9)
{
a=1;
while(a%d!=0)
{
cout<<1;
a=((a%d)*10)+1;
}
cout<<"/"<<d<<"\n";
getch();

d=d-2;
d=d*10+3;
j++;
}
getch();
}

- BIPLOVESARKAR August 24, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

private static int cal(int num) {
int total = 3;
int model = 100 % num;
int begin = 11;
while ((model + begin) % num != 0) {
begin = (model + begin) % num;
model = (10 * model) % num;
total++;
}
return total;
}

- Praveen December 02, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

nice solution!!

- Anonymous January 09, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Perform (111...111/num), where the number of ones keeps on increasing till the remainder is zero.

private static int cal(int num) {
int total = 3;
int x = 111;

while (x % num != 0) {
int remainder = x % num;
x = remainder * 10 + 1;
total++;
}
return total;
}

- Praveen Garg December 02, 2011 | Flag Reply


Add a Comment
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.

Learn More

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.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More