## Epic Systems Interview Question for System Administrators

• 0

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).

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);

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

return 0;
}

PNODE Init(int * min, int * max){
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;

}
}
}

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

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

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?

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

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.

### 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.