Epic Systems Interview Question for Developer Program Engineers


Country: United States




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

#include <iostream>
#include <string>
#include <vector>

using namespace std;

void textPermutation(vector<int>& visited, string& str, string& working) {
    if (str.size() == working.size()) {
        cout << working << "\n";
    }
    
    for (int i = 0; i < str.size(); i++) {
        if (visited[i] == 0) {
            visited[i] = 1;
            working.push_back(str[i]);
            textPermutation(visited, str, working);
            working.erase(working.size() - 1, 1);
            visited[i] = 0;
        }
    }
}

int main()
{
   string str, working;
   vector<int> visited;
   
   working = "";
   str = "tree";
   for (int i = 0; i < str.size(); i++) {
        visited.push_back(0);
   }
   
   textPermutation(visited, str, working);
   
   return 0;
}

- kyduke April 16, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public static void main(String[] args) {
	  Set<String> stringSet = new HashSet<String>();
	  getPermutationOfString("tree".toCharArray(), 0, stringSet);
	  printSets(stringSet);
}

public static void getPermutationOfString(char[] a, int i, Set<String> stringSet) {
	if (i == a.length) {
		stringSet.add(new String(a));
	} else if (i < a.length) {
		for (int j = i; j < a.length; j++) {
			swap(a, i, j);
			getPermutationOfString(a, i + 1, stringSet);
			swap(a, i, j);
		}
	}
}

public static void swap(char[] a, int i, int j) {
	char temp = a[i];
	a[i] = a[j];
	a[j] = temp;
}

public static void printSets(Set<String> strs) {
	for (String string : strs) {
		System.out.println(string);
	}
}

- guilhebl April 16, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

//Note : Here Repetations allowed
// Means when same char comes again then same word would be repeated.

package recursion;

public class Permutation {

public static void main(String[] args) {
String str = "tree";
//permu(str, str.length(), "");
combi(str, str.length(), "");
}

private static void permu(String str, int len, String out) {

if(out.length() == len){
System.out.println(out);
return;
}

for(int i = 0;i < str.length(); i++){
permu(str, len, out+str.charAt(i));
}
}

private static void combi(String str, int len, String out) {

if(out.length() == len){
System.out.println(out);
return;
}

for(int i = 0;i < str.length(); i++){
combi((str.substring(0,i)+""+str.substring(i+1)), len, out+str.charAt(i));
}
}
}
/*Answers
tree
tree
tere
teer
tere
teer
rtee
rtee
rete
reet
rete
reet
etre
eter
erte
eret
eetr
eert
etre
eter
erte
eret
eetr
eert*/

- Allwin S April 16, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I'm using a Set in order to avoid having duplicate Strings, this happens due to the string having non-unique chars.

- guilhebl April 16, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

import java.util.LinkedList;

public class hello{

public static void main(String args[]){
String str = "tree";
LinkedList<String> permutation = new LinkedList<>();
LinkedList<String> combinator = new LinkedList<>();
int i=0;
while(i<str.length()){
char s = str.charAt(i);
permutation.add(s+"");
i++;
}


for(int j=0;j<permutation.size();j++){
String sr = permutation.get(j);
permutation.remove(j);
combinator.addAll(permutation);
combinator.add(j,sr);
permutation.add(j, sr);
}
System.out.print(combinator.toString());
}

}

- topcoder May 25, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

import java.util.LinkedList;

public class hello{
	
	public static void main(String args[]){
		String str = "tree";
		LinkedList<String> permutation = new LinkedList<>();
		LinkedList<String> combinator = new LinkedList<>();
		int i=0;
		while(i<str.length()){
			char s = str.charAt(i);
			permutation.add(s+"");
			i++;
		}
		
		
		for(int j=0;j<permutation.size();j++){
			String sr = permutation.get(j);
			permutation.remove(j);
			combinator.addAll(permutation);
			combinator.add(j,sr);
			permutation.add(j, sr);
		}
		System.out.print(combinator.toString());
	}
	
}

Generates only :[t, r, e, e, r, e, e, t, e, e, t, r, e, t, r, e]

- topcoder May 25, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

[t, r, e, e, r, e, e, t, e, e, t, r, e, t, r, e]

- topcoder May 25, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

static HashSet<String> result = new HashSet<String>();
	public static void wordPerm(String prefix, String input){
		int len = input.length();
		
		if (len == 0){
			result.add(prefix);
		}
		
		else {
			for (int i=0; i<len; i++){
				wordPerm(prefix+input.charAt(i), input.substring(0,i)+input.substring(i+1));		
			}
		}

}

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

static HashSet<String> result = new HashSet<String>();
	public static void wordPerm(String prefix, String input){
		int len = input.length();
		
		if (len == 0){
			result.add(prefix);
		}
		
		else {
			for (int i=0; i<len; i++){
				wordPerm(prefix+input.charAt(i), input.substring(0,i)+input.substring(i+1));		
			}
		}
	}

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

Import itertools

String = input('Type a word: ')
com = itertools.permutations(String)

for val in com:
print(*val)

- thatPythonGuy April 18, 2021 | 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