Adobe Interview Question for SDE-3s


Country: United States




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

int repeatedDigitCount(int num,int k){

int i,count = 0;
for(i=0;i<=num;i++){

if(i==0 && k==0)
{
count++;
continue;
}

if(i==1 && k==1)
{
count++;
continue;
}

int val = i;
while(val>1){

if(val%10 == k){
count++;
}
val = val/10;
if(val==k && val!=0){
count++;
}
}


}
return count;
}

- Anonymous January 15, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote
- amruthank196 January 15, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public int getTotalOccurrences(int[] list, int k) {
		int occurrences = 0;
		for(int i : list) {
			if(i == k) {
				occurrences++;
			}
			if(i > 9) {
				while(i > 9) {
					int reminder = i % 10;
					if(reminder == k) {
						occurrences++;
					}
					i = i / 10;
					if(i == k) {
						occurrences++;
					}
				}
			}
		}
		return occurrences;
	}

- srammer January 15, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

private static int countRep(int[] numbers, int toCheck) {
		int count = 0;
		for (int element : numbers) {
			if (element < 9) {
				if (element == toCheck) {
					count++;
				}
			} else {
				int rem = 0;
				int org = element;

				while (org > 0) {
					rem = org % 10;
					if (rem == toCheck) {
						count++;
					}

					org /= 10;
				}
			}
		}

		return count;
	}

- root January 18, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

if(element < 9

will discard the digit 9. You should replace that with

if(element < 10

or

if(element <= 9

- Manan February 01, 2019 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

N = 50
alist = [x for x in range(N)]
print(alist)
#print(alist)
#print('HI')
k = 3
count=0
for i in range(len(alist)):
    if alist[i]==k: count+=1
    elif alist[i] > 9:
        temp = alist[i]
        while (temp>9):
            if temp%10==k: count+=1
            temp = temp//10
            if temp==k: count+=1
print(count)

- snakeonbasket January 19, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

ZoomBA. Spec is not very clear - but this is what is approximating the problem :

def find_occurences( numbers , k ){
  sk = str(k)
  sum ( numbers ) -> { sk @ str($.o) ? 1 : 0 }
}
println( find_occurences ( [0,10] , 0 ) )

- NoOne January 15, 2017 | 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