Qualcomm Interview Question for Software Engineer / Developers


Country: India




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

package Questions;

public class MaxOneDiff {

	public static void main(String[] args) {
		int k = 4;
		getList(k);
	}

	public static void getList(int k) {

		int arr[] = new int[k];
		int index = 0;
		printRecList(k, arr, index, k);

	}

	public static void printRecList(int k, int arr[], int index, int range) {

		if (k == 0) {
			for (int i = 0; i < arr.length; i++) {
				System.out.print(arr[i]);

			}
			System.out.println();
		} else {

			for (int i = 1; i <= range; i++) {
				if (index == 0) {
					arr[index] = i;
					printRecList(k - 1, arr, index + 1, range);

				}
				else{
					int t=arr[index-1]-i;
					t=t>0?t:-t;
					if(t<2){
						arr[index] = i;
						printRecList(k - 1, arr, index + 1, range);

						
					}
					
					
				}
			}

		}

	}

}

- bhawna May 14, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

1232 ? Is it wrong?

- Chengyun April 02, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

no 1232 is correct I guess i missed it..

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

no 1232 is correct I guess i missed it..

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

i think 1213 should not be there..

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

it is correct..

- prathimzn July 27, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Assuming n is the length of the input sequence :-
Assuming p1.....pn be the numbers of length n, and p1 to pn = 1.
for (i=1 to n-1) {
T(n)
}

T(k) {
if ( p(k) == p(k-1) {
p(k) = p(k) + 1;
}
print (p);
T(k-1)
}

Here print p will print the the updated p values.

- Jaiprakash April 03, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

why have you missed 0? If 121 is a valid solution (for the case of k=3), why shouldn't we have 110?

- G April 06, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

void dfs(int pos,int now,int mn,int k)
{
if(pos==k) printf("%d\n",now);
else
{
for(int i=1;i<=mn+1&&i<10;i++)
{
dfs(pos+1,now*10+i,max(mn,i),k);
}
}
}

dfs(0,0,0,k);

- zhao April 07, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

void PrintAllArangments(int Num,int *Out,int Pos,int Size)
{
if(Pos == Size)
{
for(int i = 0; i < Size; ++i)
{
cout << Out[i] << ",";
}

cout << endl;
}
else
{
for(int i = 1; i <= Num; ++i)
{
if(i <= Pos + 1)
{
Out[Pos] = i;
PrintAllArangments(Num,Out,Pos + 1,Size);
}
}
}
}

- Guy April 09, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

bhak

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

Please help me in understanding this question with some more examples.

- DashDash May 05, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<stdio.h>
int n;
void fun(int *a,int j)
{
int k,i;
if(j==n)
{
for(i=0;i<n;i++)
printf("%d",a[i]);
printf("\n");
return;
}
for(j,k=0;k<=j;k++)
{
a[j]=k+1;
fun(a,j+1);
}
}
int main()
{
scanf("%d",&n);
int a[n],i;
fun(a,0);
return 0;
}

- prathimzn July 27, 2012 | 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