Epic Systems Interview Question for Software Engineer / Developers






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

int size;
void dig_gen(int m,int n, char* passwd)
{
int i,j;
if(n==size-1)
{
for(i=m;i<=9;i++)
{
passwd[n]='0'+i;
for(j=0; j<size; j++)
printf("%c",passwd[j]);
printf("\n");
}
}
else
{
for(i=m;i<10-size+n+1;i++)
{
passwd[n]='0'+i;
dig_gen(i+1,n+1,passwd);
}
}
}
void main()
{
char* passwd;
scanf("%d",&size);
passwd=malloc(sizeof(char)*size);
dig_gen(0,0,passwd);
free(passwd);
}

- recursion-andrewzp February 08, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

very good code.....good work andrewzp

- Swapnil May 11, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Dude Excellent work!!!!! U are a genius, if you have answered this one in just 20min of the exam time.

- Satya July 05, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Do you expect your interviewer to understand this line??
"for(i=m;i<10-size+n+1;i++)"

- Anonymous October 21, 2009 | Flag
Comment hidden because of low score. Click to expand.
-1
of 1 vote

extremely bad code! no documentation and worst naming practices ever

- abc March 13, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

love the code..ignore the haters

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

love the code..ignore the haters

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

any explanation ? i find it extremely difficult to understand

- Anonymous September 27, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Generate the number first using N. Its probably something like
for(int i = 1; i<10; i+2)
{
for(int j = 1; j<10^N; j+2)
{
generatenumber = i*10^N + j;
something-------

check the digits using another function... best i could come up with...

- Amon February 12, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

please dont become a programmer! change your profession

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

little bit of comments in the code would make it easier to understand

- dan February 25, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Please note:
1.strictly ascending
2. N digits

Solution:
if (N<= 0) printf( "No solution\n");
if (N == 10) return printf( "01234456789\n");
for (i1=0; i1< 10-N; i1++)
{
printf("%1d");
if (N<9)
for (i1=1; i1< 10-N; i1++)
{
printf("%1d");
if (N<8)
for (i1=1; i1< 10-N; i1++)
{

... ...
}
}
}
prinf("\n");

- kulang February 25, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

My mi
stakes:

Should be:

Solution:
if (N<= 0) printf( "No solution\n");
if (N == 10) return printf( "01234456789\n");
for (i1=0; i1< 10-N; i1++)
{
printf("%1d", i1);
if (N>1)
for (i2=i1+1; i2< 10-N; i2++)
{
printf("%1d", i2);
if (N>2)
for (i3=i2+1; i3< 10-N; i3++)
{
... ...
if (N>8)
for (i9=i8+1; i9< 10-N; i9++)
{
printf("%1d", i9);
}
... ...
}
}
}
prinf("\n");

- kulang February 25, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Sorry, more mistakes:
for (i1=0; i1< 10-N; i1++)
{
printf("%1d", i1);
if (N>1)
for (i2=i1+1; i2< 10-N+1; i2++)
{
printf("%1d", i2);
if (N>2)
for (i3=i2+1; i3< 10-N+2; i3++)
{
... ...
if (N>8)
for (i9=i8+1; i9< 10-N+8; i9++)
{
printf("%1d", i9);
}
... ...
}
}
}
prinf("\n");

- kulang February 25, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

int main()
{
int N=5;
int num_array[N];
posnos(N ,-1, num_array);
return 0;
}

int posnos(int n, int val, int* array)
{
int i;
if(n<=0) {
for(i=4; i>=0; i--)
printf("%d", array[i]);
printf("\n");
return;
}

for(i = val+1; i<10; i++) {
array[n-1] = i;
posnos(n-1, i, array);
}
}

- ajeet March 16, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<stdio.h>
#include<stdlib.h>
int main()
{
int N;
printf("enter the length of the password ");
scanf("%d",&N);
int x,i,j,a;
//since the password should be desired it should always start with (10-N)th
//digit to satisfy the desired condition
for(x=1;x<=(10-N);x++)
{
//start from number greater tham the first digit
for(i=x;i<=(10-N);i++)
{
printf("%d",x);
//go N times adding 1 to the previous digit
for(a=1;a<N;a++)
{

printf("%d ",(i+a));

}

printf("\n");
}
}
}

- Anonymous March 26, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

cannot get all the numbers. you can just get numbers which are adjacent, like 234,345,567 but not 134,145 etc.,

- Debug April 15, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

// This code is written if the number of digits in the pass word are 4.... the code could be modified accordingly for more numbers in the password.
public class DesirableNumber
{

public static void main(String args[]){
int numberOfDigits = 4;

for(int i = 0;i<9;i++){
for(int k =0;k<9;k++){
for(int j =0;j<9;j++){
String number = i+""+j+"" +k;

if(number.length() < numberOfDigits){
FindDesirable(number);
}else{
break;
}
}
}
}

}

private static void FindDesirable(String number) {

char a = number.charAt(0);
char b = number.charAt(1);
char c = number.charAt(2);
if(a<b && b<c){
System.out.println(number);
}
}
}

- Anonymous March 30, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

how can you change your code if the length is unknown? I mean if the user provides the length ..
you are assuming that you know the length which is not correct..

- Debug April 15, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

AllDesirable ad = new AllDesirable();
			StringBuffer output = new StringBuffer(Integer.parseInt(argv[1]));
			for (int i = 0; i < Integer.parseInt(argv[1]); i++)
				output.append('0');
			ad.printMe(Integer.parseInt(argv[1]), 0, output, 0);

public class AllDesirable {
	public void printMe(int n, int start, StringBuffer output, int level){
		if (n == level){
			System.out.println(output);
			return;
		}
		
		for (int i = start; i <= 9; i++){
			output.setCharAt(level, (char) (i + '0'));
			printMe(n, i + 1, output, level + 1);
		}
	}
}

- Anonymous August 04, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

This comment has been deleted.

- Administrator August 22, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Good one dude

- Anon August 30, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

.

- xxx April 22, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

int N = 5;
int[] a = new int[N];
getDigit(0, 0, N, a);

public static void getDigit(int digit, int i, int length, int[] a)
{
if(digit==length-1)
for(int j=i;j<=9;j++)
{
a[digit] = j;
for(int num:a)
System.out.print(num);
System.out.println();
}
else
for(int j=i;j<=9;j++)
{
a[digit] = j;
getDigit(digit+1, j+1, length, a);
}
}

- Sean September 08, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Goal: Find all K-combinations (in lexographic order) of 9 digits.

Pseudo Code:

//this function finds the next combination in lexographic order
Nextcomb(comb)
{
while (comb != Lastcomb) do
{
print(comb);
B = comb;
i = 0;
while (i < K) and (B[i+1] == B[i]+1) do
{
B[i] = i; // if there is no gap in elements, and the end has not reached, then B[i]=i;
i++;
}
B[i] = B[i]+1; // otherwise, jump by 1;
Nextcomb(B);
}
}


//Main function
Input = K; // length of password
Lastcomb = 9-K+1,9-K,...,9;
Firstcomb = 0,1,2,3,...,K-1;

Nextcomb(Firstcomb);

- chao October 09, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

List<Integer> PasswordList(int startInt, int N)
{
List<Integer> finalList=new ArrayList<Integer>();
int R = 9-N+1;
if(N==1)
{
for(int t=startInt;t<=9;t++)
{
finalList.add(t);
}
return finalList;
}
for(int i=startInt;i<=R;i++)
{
List<Integer> prevList = PasswordList(i+1,N-1);
for(int j=0;j<prevList.size();j++)
{
Double temp = Math.pow(10,(N-1));
finalList.add(i*temp.intValue() + prevList.get(j));
}
}
return finalList;
}

- Anonymous October 23, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public class Desire2 {

/**
* @param args
*/
public static void main(String[] args) {
desireNum("0",4);


}

public static void desireNum (String output,int level){
if(level==0){
System.out.print(Integer.parseInt(output)+" ,");
return;
}
for(int i=1;i<10;i++){
if(Integer.parseInt(output.charAt(output.length()-1)+"")<i){
//System.out.println(output.charAt(output.length()-1)+" "+i+" level"+level);
desireNum(output+i,level-1);
}
}

}

}

- Nick November 02, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<stdlib.h>

void main()
{
int i, n, j, k, flag, lb, ub, x, y, cnt;
char c[10];
clrscr();
printf("\nEnter digits: ");
scanf("%d",&n);
lb=pow(10,n-1);
ub=pow(10,n);
cnt=0;

for(i=lb;i<ub;i++)
{

itoa(i,c,10);

flag=0;
for(j=0;j<n-1;j++)
{
x=c[j];
y=c[j+1];
if(x<y)
flag=flag+1;
}

if(flag==(n-1))
{ printf("\t");
cnt=cnt+1;
for(k=0;k<n;k++)
printf("%c",c[k]);
}

}
printf("\nTotal no. of desirable numbers having %d digits is: %d",n,cnt);

getch();
}

- Anonymous November 11, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Here's Python:

def getDesirables(N):
    if N < 1:
        return None
    if N is 1:
        return [str(i) for i in range(10)]
    desirables = []
    for s in getDesirables(N-1):
        last_digit = int(s[-1])
        for t in range(last_digit+1,10):
            desirables.append(s+str(t))
    return desirables

print(getDesirables(0)) # N must be positive, else None
print(getDesirables(1))
print(getDesirables(2))

- Bullocks December 29, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Oops ... let's not forget to exercise N >= 10:

print(getDesirables(10)) # 0123456789
print(getDesirables(11)) # should get empty list

- Bullocks December 29, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

void ordercombination(int n, char *out, int permlen, int start)
{
if(n == permlen)
{
cout<<out<<endl;
return;
}
for(int i=start;i<10;i++)
{
out[permlen] = i + '0';
ordercombination(n,out,permlen+1,i+1);
}
}

- Tushar April 08, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

package b;

public class DesirableNum {
	public static void main(String[] args){
		int N = 3;			
		printDesirable("", 0, N);
	}
	
	public static void printDesirable(String op, int start, int N){
		if(N == 0){
			System.out.println(op);
			return;
		}
					
			for(int i = start; i < 10; i++){
				String initial = op;
				op += i;
				printDesirable(op, i+1, N-1);				
				op = initial;				
			}	
	}
}

- Dr. Java April 25, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

{{
main(N)
{
// form smallest N digit no
int num = pow(10,N-1);
while(num<pow(10,N))
{
status = checkAscending(num,N);
if status == -1
num++;
else
print(num)
}
}
checkAcending(num,N)
{
char *n = itoa(num);
for(i=0;i<N-1;i++)
{
if n[i]>n[i+1]
return(-1);
}
return(1);

}

- Ashwin June 10, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

<pre lang="c#" line="1" title="CodeMonkey35355" class="run-this"> class Combination
{
static void Main(string[] args)
{
Console.Write("Enter Length: ");
int length = Convert.ToInt32(Console.ReadLine());
Combinations(length, "", 0);
Console.ReadLine();
}

private static void Combinations(int length, string combination, int intIndex)
{
if (combination.Length == length)
{
Console.WriteLine(combination);
}
else if (combination.Length < length)
{
for (int i = intIndex; i < 10; i++)
{
string newCombination = combination + i.ToString();
Combinations(length, newCombination, ++intIndex);
}
}
}
}</pre>

- Anonymous October 16, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

// Good question for practice
// Here is pesudo code , very simple
str = string of n length
For(i = 1;i<9-N;i++)
{
str[0] = ‘0’+i;
Print_desire(str,1,N,i);
}

Print_desire(char *str,int i,int n,int k)
{
If(i>=N)
{
Return;
}
If(i==N-1)
{
Print str;
}
For(j = 2;j<9;j++)
If(j>i)
{
Str[i] = ‘0’+j;
Print_desire(str,i+1,n,j);
}




}


}



// let me know if it is wrong !

- Mohit Nagpal April 14, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

one typo ,
if(j > k) instead of if(j > i)

- Mohit Nagpal April 14, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

//sort the numbers . Since it would n digits only, so we could use count sort,
    //then use the permutation and avoid if the number is repeating. 
    class Program
    {
        static void Main(string[] args)
        {
            int[] digits = { 1, 2, 4, 5, 7, 8};
            bool[] used = new bool[digits.Length];
            Permutation(digits, used, 0, digits.Length-2, "",-10);
            Console.Read();
        }
        public static void Permutation(int[] digits, bool[] used, int count, int length, string result,int pre)
        {
            if (count == length && result != " ")
            {
                Console.WriteLine(result);               
                return;
            }
            for (int i = 0; i < digits.Length; ++i)
            {
                if (used[i]||pre > digits[i])
                    continue;
               
                pre = digits[i];
                used[i] = true;
                Permutation(digits, used, count + 1, length, result +" "+ digits[i],pre);           
                used[i] = false;
            }

        }
    }

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

#include<iostream>
using namespace std;
void listAllOrderedNumbers(int str[],int length,bool mask[]);
int main()
{
int str[5];
str[0]=-1;
int length=1;
bool mask[10];
for(int i=1;i<=9;i++)
	mask[i]=false;
listAllOrderedNumbers(str,1,mask);
}
void listAllOrderedNumbers(int str[],int length,bool mask[])
{	
	if(length==5)
	{
		for(int j=1;j<5;j++)
			cout<<str[j]<<" ";
		cout<<endl;		
	}
	else
	{	
		for(int i=1;i<=9;i++)
		{
				if(mask[i]==true)
					continue;
				if(str[length-1]< i)
				{
					str[length]=i;
					mask[i]=true;
					listAllOrderedNumbers(str,length+1,mask);
					mask[i]=false;
				}
		}	
	}	
}

- Anonymous February 26, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public void printNum(int digits)
{
genNums(0,digits,-1,"");
}

public void genNums(int idx, int digits, int lastNum, String temp)
{
if(temp.length() == digits)
{System.out.println(temp); return;};

for(int n=lastNum+1;n<=10-digits+idx;n++)
{
genNums(idx+1,digits,n,temp+String.valueOf(n));
}
}

- dongqiao February 28, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public void printNum(int digits)
  {
    genNums(0,digits,-1,"");
  }
  
  public void genNums(int idx, int digits, int lastNum, String temp)
  {
    if(temp.length() == digits) 
    {System.out.println(temp); return;};
      
    for(int n=lastNum+1;n<=10-digits+idx;n++)
    {
        genNums(idx+1,digits,n,temp+String.valueOf(n));
    }
  }

- dongqiao February 28, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

/*
 * password.cpp
 *
 *  Created on: Aug 13, 2012
 *    
 */

#include <stack>
#include <stdio.h>
using namespace std;
void pass(stack <int> a,int n)
{
 if(n==0)
 {
	 while(!a.empty())
	 {
		 printf("%d ",a.top());
		 a.pop();

	 }
	 printf("\n");
 }

 else{

	  for(int i = 0;i<a.top();i++)
	  {
		  a.push(i);
		  pass(a,n-1);
		  a.pop();

	  }

 }

}
int main()
{
int n;
scanf("%d",&n);
  stack <int> a;
  a.push(9);
  pass(a,n-1);
}

- manish kumar August 13, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Like most of the other code, I am using tail recursion. When numDigits is 0, I will just print what I have so far in the "curr" argument. Otherwise I will construct the new "curr" argument by multiplying it by 10 and adding the next digit to it. My only "innovation" is the use of the ones-digit to determine the minimum digit I should start iterating from.

static void printAll(int numDigits, int curr) {
	if(numDigits == 0) {
		System.out.println(curr);
		return;
	}
	int min = 1 + (curr > 0 ? curr%10 : 0);
	for(int d=min; d<=9; d++) {
		printAll(numDigits-1, curr*10 + d);
	}
}

- Sunny December 17, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

int permutation_without_repetition(int start,int size,int index,char* password)
{
   int num_of_instance=0;
   if(size == 0) 
   {
       cout<<password<<endl;
       return 1;
   }
   for(int i=start;i<=10-size;i++)
   {
       password[index]='0'+i;
       num_of_instance += permutation_without_repetition(i+1,size-1,index+1,password);
   }
    return num_of_instance;
}

void password_prob(int size)
{
    char* password;
    
    if(size>0){
        password = new char[size];
        int count = permutation_without_repetition(0,size,0,password);
        cout<<"No. of possible passwords: "<<count<<endl;
    }
    else
    {
        cout<<"Invalid input !";
    }
}

According to the problem, I rarely find any of above solutions which gives correct output. can you please look into this? Comments and feedbacks are highly appreciatable. Thanks.

- Sheikh Mamun January 08, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author dell
*/
public class Main2 {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
new Main2().substringCombination("", 3, 0);
}

public void substringCombination(String prefix, int n, int k) {
if (n == 0) {
System.out.println(prefix);
return;
}
for (int i = k+1; i <=9; i++) {
substringCombination(prefix +i , n-1,i);
}
}
}

- munir1690 August 05, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<stdio.h>

void print(int dig,int n,char *str,int ind)
{
    if(dig<=0)
    {
        str[ind]='\0';
        printf("%s\n",str);
        return;
    }
    else
    {
        for(int i=n;i<=9;i++)
        {
            str[ind]=i+48;
            print(dig-1,i+1,str,ind+1);
        }
    }
}

int main()
{
    int n;
    char str[3];
    print(3,0,str,0);
}

- Rachit September 13, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#!/usr/bin/python

##print password recursively from leftmost digit
##s is current string, minv is min value of leftmost digit, m is number of digits
def printPW(s, minv, m):
    for v in range(minv, 11 - m):
        if m==1:
            print s + str(v)
        else:
            printPW(s + str(v), v + 1, m - 1)

printPW('', 6, 3)

- eastflag163 October 26, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include <stdio.h>

void print(int arr[], int n)
{
int i;
for(i=0;i<n;i++)
{
printf("%d->",arr[i]);
}
printf("\n");
}

void generatePass(int arr[],int n, int start, int index)
{
int i;

// base case:
if(index == n)
{
print(arr,n);
}

// processing
for(i=start;i<=9;i++)
{
arr[index] = i;
generatePass(arr,n,i+1,index+1);
}
}

int main(void) {
// your code goes here
int arr[3];
int n=3;
int start =1;
int index = 0;
generatePass(arr,n,start,index);
return 0;
}

- alien March 21, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include <stdio.h>
#include <stdlib.h>

int valid(int n)
{
        int temp = n / 100, first = n % 10, second = (n/10) % 10;
        if(first <= second)
                return 0;
        while(temp > 0)
        {
                first = second;
                second = temp % 10;
                if(first <= second)
                        return 0;
                temp = temp / 10;
        }
        return 1;
}

void ascending(int s, int e, int size)
{
        int i =0;
        for(i=s;i<=e;i++)
        {
                if(valid(i))
                        printf("%d\n",i);
        }
}

int main()
{
        int start = 1, end =1, i=0, size = 2;
        for(i=1;i<size;i++)
                start = start * 10;
        end = start * 10 - 1;
        ascending(start, end, size);
        return 0;
}

- kkkk October 17, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public static void main(String[] args) 
	{
		String s = "";
		int n = 5;
		func(s,n,0);
	}
	
	static void func(String s, int n, int j)
	{
		if (s.length() == n)
		{
			System.out.println(s);
			return;
		}
		else
		{
			for (int i = j+1 ; i < 10 ; i++)
			{
				func(s+i,n, i);
			}
		}
	}

- Indranil November 22, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

void dig_gen(int begin,int level, int sz , const int max, char* passwd) 
{ 
    int i=begin;
    int j=0;
    //printf("B=%d,L=%d,sz=%d\n",i,level,sz);
    if (level >= max)
    {
        for ( j=0;j<max;++j)
           printf("%d",passwd[j]);
        printf(",");   
        return ;
    }
    
    for (i = begin; i<= 10-sz;++i)
    {
        passwd[level]=i;
        //printf("%d",i);
        dig_gen(i+1,level+1,sz-1,max,passwd);
    }
} 

void main() 
{ 
char* passwd; 
//scanf("%d",&size); 
int size=3;
printf("start\n");
passwd=malloc(sizeof(char)*size); 
dig_gen(0,0,size,size,passwd); 
free(passwd);

}

- vg July 04, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include <bits/stdc++.h>
using namespace std;

void findDesirable(int start, string passwd, int size)
{
    if(size == 0)
        cout << passwd << endl;
    else
    {
        for(int i = start; i <= 9; i++)
        {
            string str = passwd + to_string(i);
            findDesirable(i + 1, str , size - 1);
        }
    }
}

int main()
{
    string str;
    int size = 3;

    findDesirable(0, str, size);
}

- Aditya Goel July 27, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

9

- BrownAdela September 02, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

This is basically the problem of selecting M elements from N. Here is N <= 10 (i.e., 0 -9). There are a lot of algorithms designed for this problem.

- Anonymous February 28, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 votes

What if it is a four digit number, dumbo?

- Anonymous March 15, 2010 | Flag


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