Samsung Interview Question for Developer Program Engineers


Country: India
Interview Type: Written Test




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

Question is not clear. Can you please rephrase the question and edit the question. When n > 0, doesn't it imply that it can be greater than 4?? One more doubt I have is given example for n=5
1,11,111,1111,11111,12341 , the numbers 222, 2222, 333, 3333, .... are also valid right?

- prudent_programmer March 05, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

If my understanding is correct, following is the way to solve this.
Taking a simple example of 2 numbers spread over 3 place.
array A = {1,2}; n=3
say the number is: xyz
I see that repetition is allowed, as per the example.
when n=3, we have to take into account n=2 and n=1 based on what I see from the example given in the question.
x can have 1 or 2; y also can have 1 or 2; z also can have 1 or 2.
So the possibilities of all types of 3 digit numbers is: 2*2*2 = 8
Same way, possibilities of all types of 2 digit numbers is 2*2=4
Same way possibilities of all types of 1 digit number is 2
In this case answer would be 14.

Going by this, following snippet would reap the result.

numOfPlaces = 1
while(numOfPlaces<=n) {
result = result + array.length ^ numOfPlaces;
numOfPlaces++;
}

Note: I have not tested the while loop. but conceptually, I believe I have given a fair answer based on the question.
Correct me if wrong.

- Ram May 21, 2018 | 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