Epic Systems Interview Question for Software Engineer / Developers


Country: United States
Interview Type: Written Test




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

If additional memory is allowed we can use 2 arrays one for rows and one for columns and two variables for keeping track of diagonals......

Increase the count at row index by one and the same for columns...and increase the diagonal count if i == j

also to keep track of repeated random nos we can always find the index of the no which is generated and check at that index if it is present already or not....to find the index of the no divide the no by n the row will the quotient and the column will be the remainder..if the remainder is 0 then place it in the last column with the row being the quotient....

- iamthe0ne October 29, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
2
of 4 vote

public class CheckMingle {
	int[][] matrix = new int[10][10];
	static int count = 0;
	static boolean diagChecked=false;
	void initial() {
		for (int i = 0; i < matrix.length; i++) {
			for (int j = 0; j < matrix[0].length; j++) {
				matrix[i][j] = 0;
			}
		}
	}
	void printMingle() {
		for (int i = 0; i < matrix.length; i++) {
			for (int j = 0; j < matrix[0].length; j++) {
				System.out.print(matrix[i][j] + "    ");
			}
			System.out.println();
		}
	}
	void isMingo(int[][] matrix) {
		int value = 0;
		int row = 0;
		int col = 0;
		int data = 0;
		for (int i = 0; i < 100; i++) {
			value = (int) (Math.random() * 100);
			row = value / 10;
			col = value - row * 10;
			while (matrix[row][col] != 0) {
				value = (int) (Math.random() * 100);
				row = value / 10;
				col = value - row * 10;
			}
			data = (int) (Math.random() * 1000);
			matrix[row][col] = data;
			checkMingle(matrix, row, col);
		}
		
	}
	void checkMingle(int[][] matrix, int row, int col) {
		// check row
		int index = 0;
		while (index < matrix[row].length && matrix[row][index] != 0) {
			index++;
		}
		if (index == matrix[row].length) {
			count++;
			System.out.println("Number " + count + " mingle"+" row:"+row);
		}
		// check column
		index = 0;
		while (index < matrix.length && matrix[index][col] != 0) {
			index++;
		}
		if (index == matrix.length) {
			count++;
			System.out.println("Number " + count + " mingle"+" col: "+col);
		}
		//check diag
		if(!diagChecked){
				index=0;
				while(index<matrix.length&&matrix[index][index]!=0){
					index++;
			}
			if(index==matrix.length){
			count++;
			System.out.println("Number " + count + " mingle"+" row:"+row+" col: "+col+"It is diag!!!!");
			diagChecked=true;
			}
			
		}
	}
	public static void main(String[] args) {
		CheckMingle cm = new CheckMingle();
		cm.initial();
		cm.isMingo(cm.matrix);
		cm.printMingle();
	}
}

This code did not make sure the value in each cell of matrix is unique, but since the value is from 0 to 1000, I test it and did not see cases that two cells have same value.

Anyone who got questions like this have an opinion on my concern?

- Bunnyyoung717 November 11, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
3
of 3 votes

You are just checking for one diagonal what about the other diagonal

- Anonymous March 26, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Mingo mingo = new Mingo();
mingo.Init();

Random r = new Random(100);
for (int i = 0; i < 100; i++)
{
mingo.setMingoValue(r.Next(1, 100));
mingo.isMingo();
}

mingo.cs
============
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
public class Mingo
{

int [,] m_MingoTable = new int[10,10];
public void Init()
{

for(int i = 0; i < 10; i++)
for(int j =0; j<10;j++)
{
m_MingoTable[i, j] = 0;
}
}

public void setMingoValue(int value)
{
//sanity
if(value < 100)
{
int row = System.Math.Abs(value/10);

int col =value - row*10;
m_MingoTable[row, col] = value; //use true or false?
}
//else raise error

}

public void isMingo()
{
bool bRowMingo = true, bColumnMingo = true, bDiagonalMingo = true, bOppositeDiagMingo = true;
for(int i = 0; i < 10;i++)
{
for(int j=0;j<10;j++)
{
//all column for one row
if (m_MingoTable[i, j] == 0)
bRowMingo = false;

//column - all row
if (m_MingoTable[j, i] == 0)
bColumnMingo = false;

//diagnal (0,0), (1,1), etc..
if (i == j && m_MingoTable[i, j] == 0)
bDiagonalMingo = false;
//(9,0), (8,1),(7,2) etc,
if (((i + j) == (10 - 1)) && m_MingoTable[i, j] == 0)
bOppositeDiagMingo = false;
}
if(bRowMingo == true)
Console.WriteLine(i);
if(bColumnMingo == true)
Console.WriteLine(i);
bRowMingo = bColumnMingo = false;

}
if(bDiagonalMingo == true)
Console.WriteLine("same number diagnal");
if(bOppositeDiagMingo == true)
Console.WriteLine("Sum of coordinates diagonal");
}
}
}

- Maddy January 12, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Mingo mingo = new Mingo();
mingo.Init();

Random r = new Random(100);
for (int i = 0; i < 100; i++)
{
mingo.setMingoValue(r.Next(1, 100));
mingo.isMingo();
}

mingo.cs
============
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
public class Mingo
{

int [,] m_MingoTable = new int[10,10];
public void Init()
{

for(int i = 0; i < 10; i++)
for(int j =0; j<10;j++)
{
m_MingoTable[i, j] = 0;
}
}

public void setMingoValue(int value)
{
//sanity
if(value < 100)
{
int row = System.Math.Abs(value/10);

int col =value - row*10;
m_MingoTable[row, col] = value; //use true or false?
}
//else raise error

}

public void isMingo()
{
bool bRowMingo = true, bColumnMingo = true, bDiagonalMingo = true, bOppositeDiagMingo = true;
for(int i = 0; i < 10;i++)
{
for(int j=0;j<10;j++)
{
//all column for one row
if (m_MingoTable[i, j] == 0)
bRowMingo = false;

//column - all row
if (m_MingoTable[j, i] == 0)
bColumnMingo = false;

//diagnal (0,0), (1,1), etc..
if (i == j && m_MingoTable[i, j] == 0)
bDiagonalMingo = false;
//(9,0), (8,1),(7,2) etc,
if (((i + j) == (10 - 1)) && m_MingoTable[i, j] == 0)
bOppositeDiagMingo = false;
}
if(bRowMingo == true)
Console.WriteLine(i);
if(bColumnMingo == true)
Console.WriteLine(i);
bRowMingo = bColumnMingo = false;

}
if(bDiagonalMingo == true)
Console.WriteLine("same number diagnal");
if(bOppositeDiagMingo == true)
Console.WriteLine("Sum of coordinates diagonal");
}
}
}

- Maddy January 12, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

In the above code, only 100 numbers are generated, but haven't checked about the repetition. If a number is repeated we are re-assigning the value and we are missing a value in 100 by the end of the loop.

- Nani January 19, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I am asked this question in the online test for summer intern

- cronaldo February 05, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Rather than checking the entire board on each move, it would be faster to check the location of each move for membership in a full diagonal, row, or column, then call out "first, second..." etc. as a contiguous row is found. This way, you only have to keep track of the number of Mingos detected, and most move checks will terminate very quickly when they encounter an empty cell.

- SixDegrees August 14, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
-2
of 2 vote

Mingo mingo = new Mingo();
mingo.Init();

Random r = new Random(100);
for (int i = 0; i < 100; i++)
{
mingo.setMingoValue(r.Next(1, 100));
mingo.isMingo();
}

mingo.cs
============
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
public class Mingo
{

int [,] m_MingoTable = new int[10,10];
public void Init()
{

for(int i = 0; i < 10; i++)
for(int j =0; j<10;j++)
{
m_MingoTable[i, j] = 0;
}
}

public void setMingoValue(int value)
{
//sanity
if(value < 100)
{
int row = System.Math.Abs(value/10);

int col =value - row*10;
m_MingoTable[row, col] = value; //use true or false?
}
//else raise error

}

public void isMingo()
{
bool bRowMingo = true, bColumnMingo = true, bDiagonalMingo = true, bOppositeDiagMingo = true;
for(int i = 0; i < 10;i++)
{
for(int j=0;j<10;j++)
{
//all column for one row
if (m_MingoTable[i, j] == 0)
bRowMingo = false;

//column - all row
if (m_MingoTable[j, i] == 0)
bColumnMingo = false;

//diagnal (0,0), (1,1), etc..
if (i == j && m_MingoTable[i, j] == 0)
bDiagonalMingo = false;
//(9,0), (8,1),(7,2) etc,
if (((i + j) == (10 - 1)) && m_MingoTable[i, j] == 0)
bOppositeDiagMingo = false;
}
if(bRowMingo == true)
Console.WriteLine(i);
if(bColumnMingo == true)
Console.WriteLine(i);
bRowMingo = bColumnMingo = false;

}
if(bDiagonalMingo == true)
Console.WriteLine("same number diagnal");
if(bOppositeDiagMingo == true)
Console.WriteLine("Sum of coordinates diagonal");
}
}
}

- Maddy January 12, 2012 | 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