Epic Systems Interview Question for SDE1s


Country: United States
Interview Type: Written Test




Comment hidden because of low score. Click to expand.
6
of 10 vote

private static void maxHalves(int i, int j) {
		int firstValue, secondValue;

		int iLength = String.valueOf(i).length();
		int jLength = String.valueOf(j).length();

		if (iLength - jLength == 1) {
			firstValue = i / j;
			secondValue = i - firstValue * j;
			System.out.println("First Value:- " + firstValue
					+ " second Value:- " + secondValue);
		} else {
			System.out.println("Invalid Input");
		}

	}

- Vir Pratap Uttam April 17, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

Hi, your code seems to work only for numbers that differ by 1 in length. However I think it should't be like that. As per my understanding of code we need to print the two halves that sum up as less than or equal to the other number. Here is my implementation.

public static void splits(String number1, String number2) {
        int num = Integer.parseInt(number2);
        String half1, half2;
        for (int index = 1; index < number1.length(); index++) {
            half1 = number1.substring(0, index);
            half2 = number1.substring(index);
            if ((Integer.parseInt(half1) + Integer.parseInt(half2)) <= num) {
                // could be easily changed here to track the halves that sum 
		// closest to 2nd Number
                System.out.println(half1 + "--" + half2);
            }
        }

    }

- madhur.eng May 10, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

"Dividing" in the question means literally splitting up the first number and not dividing up to find the quotient. Check the example given by OP below

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

Could you please give an example of it.

Thank you,

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

Could you please give an example ?

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

For example 2 numbers given are 19967 and 1000
then suppose 2 halves are 19 and 967 which add upto 986 which is less than 1000. So we can print this but also try to find
if there is other pair which is even closer to 1000. So print that pair whose sum is as closest to 1000.

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

"First no have to be divided into 2 halves such that the sum of its halves must be less than or equal to the second half"? what does this even mean?

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

For example 2 numbers given are 19967 and 1000
then suppose 2 halves are 19 and 967 which add upto 986 which is less than 1000. So we can print this but also try to find
if there is other pair which is even closer to 1000. So print that pair whose sum is as closest to 1000.

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

Hi sonamist90
did you complete your Epic online test could you tell the other questions as well

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

Hi sonamist90
did you complete your Epic online test could you tell the other questions as well

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

Hi sonamist90
how did the other questions go
could you mind telling the other questions as well
what section of the careercup did the questions come from ?

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

public class twoHalsves {
	public static void main(String[] args)
	{
		int first = 31970;
		int sec = 1000;
		
		
		int div = first;
		int quotent = 0;
		
		int multiplier = 0;
		int sum = 0;
		int min = Integer.MAX_VALUE;
		
		int part1 = 0, part2 = 0;
		
		while(div!=0)
		{
			quotent = (int) (quotent + (div%10) * Math.pow(10, multiplier));
			multiplier++;
			div = (int)div/10;
			
			sum = quotent+div;
			
			if(sum<=sec)
			{
				int diff = sec - sum;
				if(diff<min)
				{
					min = diff;
					part1 = quotent;
					part2 = div;
					
				}
			}
		}
		
		System.out.println("Parts:"+ part1+" "+part2);
		
		
		
	}
}

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

int main()
{
int first = 19967;
const int second = 1000;

int h1,h2=0;
int divi = first;
int divs = 10;
int count = 1;
int mindiff =second;
while((first%divs) != first)
{
int c = (first%divs) ;
int d = (first-c)/divs;
int sum = c+d;
int diff = sum > second ? sum - second : second - sum;
if (diff < mindiff)
{
h1 =c;
h2 =d;
}
cout << "c=" << c << " d=" << d << " diff=" << diff << " divs=" << divs << endl;
divs = divs*10;
}

cout << first <<second << endl;
cout << h1 << "," <<h2;

return 0;
}

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

int main()
{
   int first = 19967;
   const int second = 1000;
   
   int h1,h2=0;
   int divi = first;
   int divs = 10;
   int count = 1;
   int mindiff =second;
   while((first%divs) != first)
   {
       int c = (first%divs) ;
       int d = (first-c)/divs;
       int sum = c+d;
       int diff = sum > second ? sum - second : second - sum;
       if (diff < mindiff)
       {
           h1 =c;
           h2 =d;
       }
       cout << "c=" << c << " d=" << d << " diff=" << diff << " divs=" << divs << endl;
       divs = divs*10;
   }
   
   cout << first <<second << endl;
   cout << h1 << "," <<h2;
   
   return 0;

}

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

int main()
{
   int first = 19967;
   const int second = 1000;
   
   int h1,h2=0;
   int divi = first;
   int divs = 10;
   int count = 1;
   int mindiff =second;
   while((first%divs) != first)
   {
       int c = (first%divs) ;
       int d = (first-c)/divs;
       int sum = c+d;
       int diff = sum > second ? sum - second : second - sum;
       if (diff < mindiff)
       {
           h1 =c;
           h2 =d;
       }
       cout << "c=" << c << " d=" << d << " diff=" << diff << " divs=" << divs << endl;
       divs = divs*10;
   }
   
   cout << first <<second << endl;
   cout << h1 << "," <<h2;
   
   return 0;

}

- vg July 02, 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