Epic Systems Interview Question for Member Technical Staffs


Country: India
Interview Type: Written Test




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

public class FindSeeds {
    public static void main(String args[]) {
        System.out.println(getSeeds(4977));
    }
    
    public static List<Integer> getSeeds(int n) {
        if(n != -1) {
            List<Integer> seedList = new ArrayList<Integer>();
            for(int i = 1; i < n; i++) {
                int seedValue = i, remain = i;
                while(remain != 0) {
                    seedValue = seedValue * (remain % 10);
                    remain = remain / 10;
                }
                
                if(seedValue == n) {
                    seedList.add(i);                
                }
            }
            return seedList;
        }
        return null;
    }

}

- saran1191 April 14, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

123*1*2*3 = 738. Not 768. Make sure when you test the sample input. The result of 768 is [];

- justthat June 28, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 2 vote

and in the question 123*1*2*3=738.
Not optimized but a quick solution:

public class SeedNumber {

public static void printSeed(int n){

for(int i=1;i<n;i++){
String nchar=Integer.toString(i);
int prod=i;
for(int j=0;j<nchar.length();j++){
int p=nchar.charAt(j)-'0';

prod=prod*p;
}

if(prod==n)
System.out.println(i);
}
}


public static void main(String[] args) {
int n=738;
printSeed(n);

}

}

- Anonymous March 29, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public void getSeeds(int n) {
	
	for (int i = 1; i <= n; i++) {

		if (isSeed(n, i)) {

			System.out.println(i);
		}
	}

}

public boolean isSeed(int target, int num) {
	
	return (getDigitProduct(num) * num == target);
}


public int getDigitProduct(int n) {
	
	if (n == 0) {

		return 0;
	}

	return (n / 10 == 0) ? n : getDigitProduct(n/10) * (n % 10);
}

- Skor March 29, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

My one is backtracking algorithm. It should work very fast.

N 23412367188, result: 13272317
N=93512378880, result: 23452182
N=615954598560, result: 13579246
N=559999999440, result: 12345679

#include <iostream>
#include <set>

using namespace std;
set<int> Result;
set<int>::iterator it;
long long N;

void init(){
    Result.clear();
};


bool check(long long N, long long P){
    long long myP = 1;
    while(N > 0){
        myP *= N%10;
        N = N/10;
    };
    return (P == myP);
}

void findSeed(long long N, long long P){
    //basecases:
    if (P > N) return;
    if (check(N,P)){
        Result.insert(N);
        return;
    }

    //recursive:
    for(int d = 9; d >= 2 ; d--)
        if (0==N%d){
            findSeed(N/d, P*d);
        };
}

int main()
{
    N = 23412367188; // result: 13272317

    init();
    if (N<10) cout <<N<<endl;
    else    findSeed(N,1);

    if (Result.size()){
        cout <<N<<": ";
        for(it= Result.begin(); it!= Result.end(); ++it)
            cout <<*it<<" ";
        cout <<endl;
    }

    return 0;
}

- ninhnnsoc March 30, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public static ArrayList<Integer> getSeeds(int number) {
        if(number != -1) {
            ArrayList<Integer> seedList = new ArrayList<>();
            for(int i = 0; i < number; i++) {
                int seedValue = getSeedValue(i, number);
                if(seedValue == number) {
                    seedList.add(i);
                }
            }
            return seedList;
        }
        return null;
    }
    
    public static int getSeedValue(int number, int targetNo) {
        if(number != -1) {
            int seedValue = number;
            while(number != 0) {
                seedValue *= (number % 10);
                number = number / 10;
                
                if(seedValue > targetNo) {
                    break;
                }
            }
            return seedValue;
        }
        return -1;
    }

- saran.1191 April 15, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
vector<int>v;
int proddig[10000];
int getdig(int x)
{
    int prod=1,temp=x;
    while(temp)
    {
        prod*=(temp%10);
        temp/=10;
    }
    return  proddig[x]=prod;
}
int main() {
    memset(proddig,0,sizeof proddig);
    long long int n;
    cin>>n;
    for(int i=1;i<=n/2;i++)
    {
        if(i*(proddig[i]?proddig[i]:getdig(i))==n)
        v.pb(i);
    }
    if(v.size()==0)
        cout<<"NO seeds exist!!!"<<endl;
    else
    {
       for(int i=0;i<v.size();i++)
         cout<<v[i]<<endl;
    }
	return 0;
}

- competitivecoder June 13, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Here is one simple solution.

public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int input = in.nextInt();
        ArrayList<Integer> seedNumbersList = new ArrayList<Integer>();
        for(int i=0; i<input/2; i++){
            char[] numStr = Integer.toString(i).toCharArray();
            int temp = i;
            for(char c:numStr){
                temp *= Character.getNumericValue(c);
            }
            
            if(temp == input){
                seedNumbersList.add(i);
            }
        }
        for(int number:seedNumbersList){
            System.out.println(number);
        }
    }

- Rajiur Rahman October 24, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

public class SeedNumber {

	public static void printSeed(int n){
	
		for(int i=1;i<n;i++){
			String nchar=Integer.toString(i);
			int prod=i;
			for(int j=0;j<nchar.length();j++){
				int p=nchar.charAt(j)-'0';
				
				prod=prod*p;
				}
		
			if(prod==n)
			  System.out.println(i);
		}
	}
	
	
	public static void main(String[] args) {
		int n=738;
		printSeed(n);

	}

}

- Anonymous March 29, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

public class SeedNumber {

	public static void printSeed(int n){
	
		for(int i=1;i<n;i++){
			String nchar=Integer.toString(i);
			int prod=i;
			for(int j=0;j<nchar.length();j++){
				int p=nchar.charAt(j)-'0';
				
				prod=prod*p;
				}
		
			if(prod==n)
			  System.out.println(i);
		}
	}
	
	
	public static void main(String[] args) {
		int n=738;
		printSeed(n);

	}

}

- lokesh March 29, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
-2
of 2 vote
- GatorsRock March 30, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

for 42 there exists seed number 21: 21*2*1 = 42

- Anonymous March 30, 2015 | 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