Epic Systems Interview Question for System Administrators






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

As we read on inputs, store the maximum odd int and minimum even int so far in two respective variables. At the end of all the inputs (user enters 0), we have ready the required output.
The company stressed on considering all input values i suppose, more of fuzzing logic (boundary conditions for inputs and stuff).

- cuppanomics May 11, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

/*
Since the question said "gives a set of numbers ", so we should consider all situations, negative, positive, float or integer. And I used  linked list here because we don't know how many numbers the user will input, so the linked list is the best way.
*/

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

typedef struct Node{
	float data;
	struct Node * pNext;
}NODE, * PNODE;

PNODE Init(int * min, int * max);

void Traverse(PNODE pHead);

int main(void){
	int minEven = 100000;
	int maxOdd = -999999;
	PNODE pHead = Init(&minEven, &maxOdd);
	Traverse(pHead);
	printf("minEven = %d, maxOdd = %d\n", minEven, maxOdd);

	return 0;
}

PNODE Init(int * min, int * max){
	PNODE pHead = (PNODE)malloc(sizeof(NODE));
	PNODE pTail = pHead;
	pTail -> pNext = NULL;
	float value = -999;
	if ( pHead == NULL )
		exit(-1);
	else{
		while(value != 0){
			PNODE pNew = (PNODE)malloc(sizeof(NODE));
			scanf_s("%f", &pNew -> data);
			value = pNew -> data;// value is the data that you should operate

			if( value == (int) value && value != 0){ // we only compare the integer value
				int intVal = (int)value;
				if(abs(intVal % 2) == 1){
					if ( intVal >= *max)
						*max = intVal;
				}
				else if(intVal %2 == 0){
					if (intVal <= *min)
						*min = intVal;
				}
			}

			pTail -> pNext = pNew;
			pTail = pNew;
			pTail -> pNext = NULL;
		
		}
	}
	return pHead;
}

void Traverse(PNODE pHead){
	PNODE pCur = pHead -> pNext;
	while(pCur != NULL){
		printf("%.2f  ", pCur -> data);
		pCur = pCur -> pNext;
	}
	printf("\n");
}

- Anonymous December 31, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

First, why would you bother to store all the numbers considering that we only need a max and min.
Second, we are looking for even number and odd number. Do you know the definition of even and odd? They are integers. Why would you bother to consider float,double or etc?

- maillist.danielyin November 23, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

import java.util.Scanner;

public class MaxOddMinEven {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		long minEven = Long.MAX_VALUE;
		long maxOdd = -1;
		while (true) {
			long nextLong = input.nextLong();
			if (nextLong == 0) {
				input.close();
				System.out.println("Max Odd Number: " + maxOdd);
				System.out.println("Min Even Number: " + minEven);
				break;
			}
			if (nextLong % 2 == 0) {
				if (nextLong < minEven) {
					minEven = nextLong;
				}
			} else {
				if (nextLong > maxOdd) {
					maxOdd = nextLong;
				}
			}
		}
	}

}

Output:
1
2
3
4
5
6
7
8
0
Max Odd Number: 7
Min Even Number: 2

- Solution September 18, 2014 | 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