Epic Systems Interview Question for Software Developers


Country: United States
Interview Type: Written Test




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

package EPIC;

import java.util.Arrays;

public class RGBCompare {
	
	public static void RGBcompare(String RGB){
		int R = Integer.parseInt(RGB.substring(0,2), 16);
		int G = Integer.parseInt(RGB.substring(2,4), 16);
		int B = Integer.parseInt(RGB.substring(4,6), 16);
		
		System.out.println("R: " + R + "  G: " + G + "  B: " + B);
		
		int rgb[] = {R,G,B};
		
		if(rgb[0] > rgb[1] ){
			switchrgb(rgb, 0, 1);
			
		}
		
		if (rgb[1] > rgb[2]) {
			switchrgb(rgb, 1, 2);
		}
		
		if (rgb[0] > rgb[1]) {
			switchrgb(rgb, 0, 1);
		}
		
		System.out.println(Arrays.toString(rgb));
		
		
		if (rgb[2] == rgb[0]) {
			System.out.println("all of them are equal");
		}else if(rgb[2] == rgb[1]) {
			System.out.println("two equal maximum");
		}else{
			System.out.println("only one maximum");
		}
	}

	public static void switchrgb(int rgb[], int i, int j){
		int t = rgb[i];
		rgb[i] = rgb[j];
		rgb[j] = t;
	}
	public static void main(String[] args) {
		
		RGBcompare("010203");
		
		RGBcompare("030201");
		
		RGBcompare("123312");
		
	}

}

- albertchenyu March 04, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

what is the meaning about the method of "switchrgb"? I don't understand that and could you explain in details. Thank you, albertchenyu!

- Tony March 09, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Hi @teargone08 switchrgb is a switch function, what I want to do first is sortting the r, g ,b array. I'm using bubble sort method, so it requires switch in two adjacent element in an array. It's just a helper function for sortting.

- albertchenyu March 09, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

now, it makes sense! Appreciate, albertchenyu!

- Tony March 10, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

public class RGBParser {

	public static void parser (String rgb) {
		
		if(rgb.length() != 6 ) {
			System.out.println("Not a valid RBB string");
			return;
		}
		
		int r = Integer.decode("0x"+rgb.substring(0, 2));
		int g = Integer.decode("0x"+rgb.substring(2, 4));
		int b = Integer.decode("0x"+rgb.substring(4, 6));
		
		//Case 1: All three values are different. Print the bigger one
		if(r != g && r != b && g != b) {
			if(r > g && r > b) {
				System.out.println("Red value is the biggest");
			} else if (g > r && g > b) {
				System.out.println("Green value is the biggest");
			} else {
				System.out.println("Blue value is the biggest");
			}
		} else if(r==g && r==b) {  // Case 2. All three colours are equal
				System.out.println("All three colours are equal");
		} else { // Case 3. Two colours are equal
			if (r==g) {
				if(r > b) {
					System.out.println("Red and green are equal and greater than Blue ");
				} else {
					System.out.println("Red and green are equal and lesser than Blue ");
				}
			}
			else if(r==b) {
				if(r > g) {
					System.out.println("Red and blue are equal and greater than green ");
				} else {
					System.out.println("Red and blue are equal and lesser than green ");
				}
			}
			else if (g==b) {
				if(g > r) {
					System.out.println("Blue and green are equal and greater than Red ");
				} else {
					System.out.println("Blue and green are equal and lesser than Red ");
				}
			}
		}
		
	}
	
	public static void main(String[] args) {
		String RGB = "F8FFFF";
		parser(RGB);

	}

}

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

public class P23 {

	private static void compare(String first, String second) {
		for (int i = 0; i < first.length(); i++) {
			if (first.charAt(i) > second.charAt(i)) {
				System.out.println("First is larger");
				return;
			} else if (first.charAt(i) < second.charAt(i)) {
				System.out.println("Second is larger");
				return;
			}
		}
		System.out.println("Equal");
	}

	public static void main(String[] args) {
		compare("010203", "030201");
	}
}

- eng.mohamed.CSD2014 July 03, 2015 | 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