Epic Systems Interview Question


Country: United States
Interview Type: Written Test




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

My c# version:

public class SpiralWrite
    {
        public int max_i = 4, max_j = 4, min_i = 0, min_j = 0;
        public char[,] matrix = new char[5, 5] {    
			{'i',	'l', 	'o', 	'v', 	'e' },
			{'d',	'i', 	'n', 	't', 	'e' },
			{'n', 	'e', 	'w', 	'e', 	'p' }, 
			{'a', 	'i', 	'v', 	'r', 	'i' }, 
			{'m',	'a', 	'x', 	'e', 	'c' } };

        public void Main()
        {
            do
            {
                for (int j = min_j; j < max_j; j++)
                    Console.Write(matrix[min_i, j]);

                for (int i = min_i; i < max_i; i++)
                    Console.Write(matrix[i, max_j]);

                for (int j = max_j; j > min_j; j--)
                    Console.Write(matrix[max_i, j]);

                for (int i = max_i; i > min_i; i--)
                    Console.Write(matrix[i, min_j]);

                max_i--;
                max_j--;
                min_i++;
                min_j++;
            }
            while (min_i != max_i || min_j != max_j);

            Console.Write(matrix[max_i, max_j]); 
        }
    }

- Aleksey Yagur April 08, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

it breaks when N is even. this also breaks when it is not a uniform matrix.

- soysauce March 07, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

c++ version:

#include <iostream>
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <climits>
using namespace std;
typedef enum my_dir{dir_up,dir_down,dir_left,dir_right}my_dir;

void print_spiral(int *matrix, int M, int N)
{
    my_dir cur_dir;
    int i=0;
    int j =0;
    int x0 =0;
    int y0 =0;
    int xn = N;
    int ym = M;

    int num =0;
    if(M==1)
    {
      for(i=0;i<N;i++)
            cout<<matrix[i]<<" ";
      return;
    }
    else if(N==1)
    {
        for(i=0;i<M;i++)
            cout<<matrix[i]<<endl;
            return;

    }
    cur_dir = dir_right;
    while(num<M*N)
    {
        switch(cur_dir)
        {
        case dir_right:
                        if(i<xn)
                        {
                            cout<<matrix[i+j*N]<<" ";
                            num++;
                            i++;
                        }
                        else
                        {
                            y0++;
                            i--;
                            j++;
                            cur_dir = dir_down;
                        }
                        break;
        case dir_down:
                       if(j<ym)
                       {
                            cout<<matrix[i+j*N]<<" ";
                            num++;
                            j++;
                       }
                       else
                       {
                           xn--;
                           j--;
                           i--;
                           cur_dir = dir_left;
                       }
                       break;
        case dir_left:
                     if(i>=x0)
                     {
                         cout<<matrix[i+j*N]<<" ";
                            num++;
                            i--;
                     }
                     else
                     {
                         i++;
                         j--;
                         ym--;
                         cur_dir = dir_up;

                     }
                     break;
        case dir_up:
                   if(j>=y0)
                   {
                       cout<<matrix[i+j*N]<<" ";
                            num++;
                            j--;
                   }
                   else
                   {
                       j++;
                       i++;
                       x0++;
                       cur_dir = dir_right;
                   }

                break;
        default:
            return;
        }

    }
}
int main()
{
    int M,N;
    int i,j;
    cout<<"Enter Matrix dimensions"<<endl;
    cin>>M;
    cin>>N;
    cout<<"ENTER "<<M*N<< " elements for the matrix"<<endl;

    int *matrix;
    matrix = (int*)malloc(M*N*sizeof(int));
    for(i=0;i<M*N;i++)
    {
        scanf("%d",matrix+i);
    }
    for (i=0;i<M;i++)
    {
        for(j=0;j<N;j++)
            cout<<matrix[j+i*N]<<" ";
        cout<<endl;
    }
    print_spiral(matrix,M,N);
    return 0;
}

- 001 November 02, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

your algorithm is awesome, but there's a little bug, the condition for the while loop should be while (min_i < max_i || min_j > max_j);, otherwise, it doesn't work for even N(column or row).

- albertchenyu February 18, 2015 | Flag
Comment hidden because of low score. Click to expand.
2
of 2 vote

It's for Java

static void spiral(char[][] mat) {
        int length = mat.length;
        int i=0, j;
        int count = 0;
        while(i < mat.length/2+1){
            i=count;
            j=count;
            while(j<length){
                System.out.print(mat[i][j++]);
            }
            j--;
            while(i<length-1){
                System.out.print(mat[++i][j]);
            }
            while(j>count){
                System.out.print(mat[i][--j]);
            }
            while(i>count+1){
                System.out.print(mat[--i][j]);
            }
            count++;
            length--;

        }
    
    }

- junpos May 19, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

this is a good one

- dx.buzzy May 30, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

the second while should be: while(j<length-1)

- diana November 10, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Sorry... I think I was wrong because it is an N*N matrix

- diana November 10, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

This one is better! it also applies matrix MxN

- soysauce February 27, 2014 | Flag
Comment hidden because of low score. Click to expand.
2
of 2 vote

I guess nobody noticed that the input to the problem is wrong?
should be

i	l	o	v	e	
d	i	n	t	e	
n	i	e	e	p	
a	v	w	r	i	
m	a	x	e	c

to get "iloveepicexamandinterview"

- abcddcba21 March 15, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

public class printSpiral {
	static int i = 0;

	public static void main(String[] args) {
		char[][] matrix = { { 'i', 'l', 'o', 'v', 'e' },
				{ 'd', 'i', 'n', 't', 'e' }, { 'n', 'e', 'w', 'e', 'p' },
				{ 'a', 'i', 'v', 'r', 'i' }, { 'm', 'a', 'x', 'e', 'c' } };
		boolean[][] used = new boolean[5][5];
		for (int z = 0; z < 5; z++) {
			for (int j = 0; j < 5; j++)
				used[z][j] = false;
		}
		printHelper(matrix, 0, 0, used);
	}

	public static void printHelper(char[][] matrix, int x, int y,
			boolean[][] used) {
		if (x > 4 || x < 0 || y > 4 || y < 0) {
			i = (i + 1) % 4;
			return;
		}
		if (used[x][y]) {
			i = (i + 1) % 4;
			return;
		} else {
			while (!checkIfArrayFull(used)) {

				System.out.print(matrix[x][y]);
				used[x][y] = true;
				if (i == 0) {
					printHelper(matrix, x, y + 1, used);
				}
				if (i == 1) {
					printHelper(matrix, x + 1, y, used);
				}
				if (i == 2)
					printHelper(matrix, x, y - 1, used);
				if (i == 3) {
					printHelper(matrix, x - 1, y, used);
					y = y + 1;
				}
			}
		}

	}

	public static boolean checkIfArrayFull(boolean[][] used) {
		for (int a = 0; a < used.length; a++) {
			for (int b = 0; b < used.length; b++) {
				if (used[a][b] == false)
					return false;
			}
		}
		return true;
	}

}

- Anonymous July 24, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 2 vote

#include<stdio.h>

int main()
{
     char arr[][5] = { 'i', 'l', 'o', 'v', 'e', 
                  'd', 'i', 'n', 't', 'e', 
                  'n', 'e', 'w', 'e', 'p', 
                  'a', 'i', 'v', 'r', 'i', 
                  'm', 'a', 'x', 'e', 'c', 
                    };
     int i, j, k,middle,size = 5;
     for(i=size-1, j=0; i>j; i--, j++)
     {
            for(k=j; k<i; k++) printf("%c", arr[j][k]);
            for(k=j; k<i; k++) printf("%c", arr[k][i]);
            for(k=i; k>j; k--) printf("%c", arr[i][k]);
            for(k=i; k>j; k--) printf("%c", arr[k][j]);
     }
     middle = (size-1)/2;
     if (size % 2 == 1) printf("%c", arr[middle][middle]);
     printf("\n\n");
     return 1;
}

- aasshishh April 07, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
2
of 2 votes

a nice logic aassshishh!

for(i=size-1, j=0; i>0; i--, j++)

should be

for(i=size-1, j=0; i>j; i--, j++)

to avoid looping unnecessarily.

- hraja123 April 08, 2013 | Flag
Comment hidden because of low score. Click to expand.
2
of 2 votes

I have used the above logic and extended it to work for matrix of any size (odd or even).

void matrix_spiral (int **arr, int size)
{    
    int x, y, z;

    for (x=0, y=size-1; x<y; x++, y--) {
        for (z=x; z<y; z++)
            printf("%5d", arr[z][x]);
        for (z=x; z<y; z++)
            printf("%5d", arr[y][z]);
        for (z=y; z>x; z--)
            printf("%5d", arr[z][y]);
        for (z=y; z>x; z--)
            printf("%5d", arr[x][z]);
    }   
    if (x==y)
        printf("%5d", arr[x][y]);

    printf("\n\n");

    return;
}

- hraja123 April 08, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

@hraha123: And still you made mistake. Find and correct it.

- Nitin Gupta April 09, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

public void displaySpiralOrder(char[][] matrix){
int N= matrix.length;
for(int row=0; row<N; row++){
if(row%2 == 0){
for(int col=0; col<N; col++){
System.out.println(matrix[row][col]);
}
}
else{
for(int col=N-1; col>=0; col--){
System.out.println(matrix[row][col]);
}
}

}
}

- Anonymous April 07, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

wrong.

- zy April 07, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

I tried to use a recursion function:

public String getSpiralOutput( char[][] matrix, int dim ) {
		String strTop = "";
		String strBottom = "";
		String strLeft = "";
		String strRight = "";
		int length = matrix.length;
		
		if( dim < 0 ) {
			return "";
		}
		
		if( length - dim*2 <= 0 ) {
			return "";
		}else if( length - dim*2 == 1 ) {
			return "" + matrix[dim][dim];
		}else if( length - dim*2 == 2 ) {
			return "" + matrix[dim][dim] + matrix[dim][dim+1] + matrix[dim+1][dim] + matrix[dim+1][dim+1]; 
		}else {
			for( int i = dim; i <= length-dim-1; i++ ) {
				strTop += matrix[dim][i];
				strBottom = matrix[length-dim-1][i] + strBottom;
			}
			for( int i = dim+1; i < length-dim-1; i++ ) {
				strRight += matrix[i][length-dim-1];
				strLeft = matrix[i][dim] + strLeft;
			}
			return strTop + strRight + strBottom + strLeft + getSpiralOutput(matrix, dim+1);
		}
	}

- zy April 07, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

dim? what is dim?

- bells April 08, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

It means "dimension" I guess.

- Aleksey Yagur April 08, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

public static void PrintSpiral(char[][] a)
	{
		int n=a.length;
		for(int i=0;i<=Math.ceil(n/2);i++)
		{
			for(int j=i;j<=n-i-1;j++)
				System.out.print(" "+a[i][j]);
			for(int j=i+1;j<=n-i-1;j++)
				System.out.print(" "+a[j][n-1-i]);
			for(int j=n-1-i-1;j>=i;j--)
				System.out.print(" "+a[n-1-i][j]);
			for(int j=n-1-i-1;j>i;j--)
				System.out.print(" "+a[j][i]);
		}
	}

- Anonymous April 08, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public class MatrixSpiralPrintBasic {

	public enum Direction {
		RIGHT, DOWN, LEFT, UP;
	}
	
	public static void printMatrixSpiral(char[][] charArray) {
		
		int xMax = charArray[0].length;
		int yMax = charArray.length;
		int xMin = 0;
		int yMin = 0;
		int xPoint = -1;
		int yPoint = 0;
		int totalCharCnt = xMax*yMax;
		int writeCharCnt = 0;
		
		Direction dir = Direction.RIGHT;
		
		while(writeCharCnt < totalCharCnt) {
			
			switch(dir) {
			
				case RIGHT:
					xPoint++;
					System.out.print(charArray[yPoint][xPoint]);
					if(xPoint == xMax-1) {
						yMin++;
						dir = Direction.DOWN;
					}
					break;
					
				case DOWN:
					yPoint++;
					System.out.print(charArray[yPoint][xPoint]);
					if(yPoint == yMax-1) {
						xMax--;
						dir = Direction.LEFT;
					}
					break;
					
				case LEFT:
					xPoint--;
					System.out.print(charArray[yPoint][xPoint]);
					if(xPoint == xMin) {
						yMax--;
						dir = Direction.UP;
					}
					break;
					
				case UP:
					yPoint--;
					System.out.print(charArray[yPoint][xPoint]);
					if(yPoint == yMin) {
						xMin++;
						dir = Direction.RIGHT;
					}
					break;
			}
			
			writeCharCnt++;
		}
		
	}
	
	public static void main(String[] args) {

		final char[][] charArray = 
			{
				{'i',	'l', 	'o', 	'v', 	'e' },
				{'d',	'i', 	'n', 	't', 	'e' },
				{'n', 	'e', 	'w', 	'e', 	'p' }, 
				{'a', 	'i', 	'v', 	'r', 	'i' }, 
				{'m',	'a', 	'x', 	'e', 	'c' } 
			};

		/*
		final char[][] charArray = 
			{
				{'a',	'b', 	'c', 	'd'},
				{'l',	'm', 	'n', 	'e'},
				{'k', 	'p', 	'o', 	'f'}, 
				{'j', 	'i', 	'h', 	'g'} 
			};
		*/

		/*
		final char[][] charArray = 
			{
				{'1',	'2'},
				{'8',	'3'},
				{'7', 	'4'}, 
				{'6', 	'5'} 
			};
		*/

		/*
		final char[][] charArray = 
			{
				{'1',	'2',	'3',	'4'} 
			};
		*/
		
		printMatrixSpiral(charArray);
		
	}
	
}

- plzeasy April 11, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

make sense

- dx.buzzy June 09, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

public void printSpiralOrder(char a[][]) {
		int m = a.length;int n = a[0].length;
		int rowStart = 0, rowEnd = m - 1, colStart = 0, colEnd = n - 1;
		while (rowStart <= rowEnd && colStart <= colEnd) {
			int i = rowStart, j = colStart;
			for (j = colStart; j <= colEnd; j++)
				System.out.print(a[i][j] + " ");
			for (i = rowStart + 1, j--; i <= rowEnd; i++)
				System.out.print(a[i][j] + " ");
			for (j = colEnd - 1, i--; j >= colStart; j--)
				System.out.print(a[i][j] + " ");
			for (i = rowEnd - 1, j++; i >= rowStart; i--)
				System.out.print(a[i][j] + " ");
			rowStart++;rowEnd--;colStart++;colEnd--;
		}
	}

- Dhass April 11, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public class SpiralPrinting {
	public static void main(String args[]){
		 char[][] matrix = 
				{
					{'i',	'l', 	'o', 	'v', 	'e' },
					{'d',	'i', 	'n', 	't', 	'e' },
					{'n', 	'e', 	'w', 	'e', 	'p' }, 
					{'a', 	'i', 	'v', 	'r', 	'i' }, 
					{'m',	'a', 	'x', 	'e', 	'c' } 
				};
		printMatrixSpiral(matrix);
	}
	public static void printMatrixSpiral(char[][] matrix){
		int numRows = matrix.length;
		int numColumns = matrix[0].length;
		int totalNodes = numRows*numColumns;
		int nodesVisted = 0;
		int startRow =0;
		int startColumn = 0;
		while (nodesVisted < totalNodes){
			int column =startColumn;
			while (column<numColumns-1){
				System.out.print(matrix[startRow][column]);
				column++;
				nodesVisted++;
			}
			int row =startRow;
			while (row<numRows-1){
				System.out.print(matrix[row][column]);
				row++;
				nodesVisted++;
			}
			while (column>startColumn){
				System.out.print(matrix[row][column]);
				column--;
				nodesVisted++;
			}
			while (row>=startRow){
				System.out.print(matrix[row][column]);
				row--;
				nodesVisted++;
			}
			startRow++;
			startColumn++;
			numColumns--;
			numRows--;
		}
	}
}

- zsljulius April 14, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public class SpiralMatrix {

	final int ROW = 5;
	final int COL = 5;
	public static void main(String[] args) {
		SpiralMatrix sm = new SpiralMatrix();
		int rowStart = 0, rowEnd = sm.ROW, colStart = 0, colEnd = sm.COL, count =0;
		int mat[][] = {{2,1,5,3,4},{5,8,6,4,4},{9,12,6,9,4},{8,7,6,5,2},{1,2,3,4,5}};
		while(count <= sm.ROW*sm.COL-1){
			//Going Right
			for(int i=rowStart, j = colStart; j<colEnd; j++ ){
				System.out.print(mat[i][j]+"\t"); count++;
			}
			rowStart++;
			//Going Down
			for(int i = rowStart, j = colEnd-1; i<rowEnd; i++ ){
				System.out.print(mat[i][j]+"\t"); count++;				
			}
			colEnd--;
			//Going Left
			for(int i = rowEnd-1, j = colEnd-1; j >= colStart; j-- ){
				System.out.print(mat[i][j]+"\t"); count++;
			}
			rowEnd--;			
			//Going Up
			for(int i = rowEnd-1, j = colStart; i >=rowStart; i-- ){
				System.out.print(mat[i][j]+"\t"); count++;
			}	
			colStart++;
		}		
	}
}

- skv May 03, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

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

void main()
{
int n=4;
char a[5][5]={'i','l','o','v','e','e','p','i','c','e','x','a','m','a','n','d','i','n','t','e','r','v','i','e','w'};

int k,i,j;

for( k=0;k<=n;k++ )
{
for( j=k; j<=n-k; j++)
printf("%c",a[k][j]);
j--;

for( i=k+1; i<=n-k; i++)
printf("%c",a[i][j]);
i--;
j--;

for( ; j>=k; j-- )
printf("%c",a[i][j]);

i--;
j++;

for( ; i>=k+1 ; i--)
printf("%c",a[i][j]);
}
}

- Abc May 08, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

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

void main()
{
int n=4;
char a[5][5]={'i','l','o','v','e','e','p','i','c','e','x','a','m','a','n','d','i','n','t','e','r','v','i','e','w'};

int k,i,j;

for( k=0;k<=n;k++ )
{
for( j=k; j<=n-k; j++)
printf("%c",a[k][j]);
j--;

for( i=k+1; i<=n-k; i++)
printf("%c",a[i][j]);
i--;
j--;

for( ; j>=k; j-- )
printf("%c",a[i][j]);

i--;
j++;

for( ; i>=k+1 ; i--)
printf("%c",a[i][j]);
}
}

- Abc May 08, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<iostream>

#define RIGHT	0
#define DOWN	1
#define LEFT	2
#define UP	   3

using namespace std;

char arr[5][5] = { 'i', 'l', 'o', 'v', 'e', 
                   'd', 'i', 'n', 't', 'e', 
                   'n', 'e', 'w', 'e', 'p', 
                   'a', 'i', 'v', 'r', 'i', 
                   'm', 'a', 'x', 'e', 'c', 
		      };

int bd_left,bd_top,bd_right,bd_bottom,bd_size=5;

int main(int argc,char* argcv[]) {
  
  int i,j,direction=RIGHT;
  bool done=false;
  
  bd_left=bd_top=0;
  bd_right=bd_bottom=bd_size-1;
  i=bd_top;
  j=bd_left;
  
  while(!done) {
    cout<<arr[i][j];
    
    switch(direction) {
      case RIGHT:
right:	j++;
	if(j==bd_right+1) {
	  j--;
	  direction=DOWN;
	  goto down;
	}
	break;
      case DOWN:
down:	i++;
	if(i==bd_bottom+1) {
	  i--;
	  direction=LEFT;
	  goto left;
	}
	break;
      case LEFT:
left:	j--;
	if(j==bd_left-1) {
	  j++;
	  direction=UP;
	  goto up;
	}	
	break;
      case UP:
up:	i--;
	if(i==bd_top) {
	  direction=RIGHT;
	  bd_left++;
	  bd_top++;
	  bd_right--;
	  bd_bottom--;
	  i=bd_top;
	  j=bd_left-1;

	  if(bd_size%2==0 && 
	    ((bd_right-bd_left) == -1) || 
	    ((bd_bottom-bd_top) == -1) ) {
		done=true;
	  }
	  else if (bd_size%2!=0 && 
	    ((bd_right-bd_left) == 0) || 
	    ((bd_bottom-bd_top) == 0) ) {
	      cout<<arr[i][++j];
	      done=true;
	      break;
	  }
	  goto right;
	}
    }
  }
  cout<<endl;
  return 0;
}

/*
Output :-
iloveepicexamandinterview
*/

- Piyush Banerjee May 20, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

This program works perfectly for all square matrices. Just change the matrix and update the bd_size variable appropriately.

- Piyush Banerjee May 20, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

/*If an N X N matrix is given, print it in spiral order.
Example: Below is 5 X 5 matrix

i l o v e
d i n t e
n i e e p
a v w r i
m a x e c
*/
#include<stdio.h>
int main()
{
    int row,col,i,move=0,j;
    scanf("%d %d",&row,&col);
    int inpMat[row][col];
    for(i=0;i<row;i++)
    {
        for(j=0;j<col;j++)
            scanf("%d",&inpMat[i][j]);
    }
    for(i=0;i<row/2;i++)
    {
        for(j=move;j<col-move;j++)
            printf("%d",inpMat[move][j]);
        for(j=move+1;j<row-move;j++)
            printf("%d",inpMat[j][col-move-1]);

        for(j=col-2-move;j>=move+1;j--)
            printf("%d",inpMat[row-1-move][j]);

        for(j=row-1-move;j>=move+1;j--)
            printf("%d",inpMat[j][move]);
        move++;
    }
    if(row%2!=0)
    {
        for(j=move;j<col-move;j++)
            printf("%d",inpMat[move][j]);
    }
}

- bhupeshkumar99 May 24, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<stdio.h>
#include<cstdlib>

int main()
{
int size,count1,count2;
int i,j,p;
int r,c;
char a[10][10];
printf("Enter the size of the square matrix(Max=5):");
scanf("%d",&size);
printf("Enter the elements of matrix:");
for(i=0;i<size;i++)
scanf("%s",&a[i]);

printf("You entered the matrix:");
for(i=0;i<size;i++)
printf("\n%s",a[i]);
printf("\n\nThe matrix written in spiral form is:");
for(r=0,c=0;c<size;c++)
printf("%c",a[r][c]);
c--;
for(p=size-1;p>0;p--)
{
count1=count2=p;
if(p==size-2|p==size-4)
{
while(count1--)
printf("%c",a[--r][c]);
while(count2--)
printf("%c",a[r][++c]);
}
else
{
while(count1--)
printf("%c",a[++r][c]);
while(count2--)
printf("%c",a[r][--c]);
}
}
printf("\n\n");

system("PAUSE");
}

- Vasu May 29, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

package com.adobe.test;

public class MatrixPrint {

public static void main(String[] args)
{


String[][] a = { {"i", "l", "o", "v", "e"}, {"d", "i", "n", "t", "e"}, {"n", "e", "w", "e", "p"}, {"a", "i", "v", "r", "i"},{"m", "a", "x", "e", "c"}};
int N = a.length;
int i=0;
int j=0;
int rowEnd = N;
int colEnd = N;
do{
printA(N, a,i,j,rowEnd,colEnd);
N = N-2 ;
i =i+1;
j= j+1;
rowEnd = rowEnd-1;
colEnd =colEnd-1;
}while (N >=1);
}

private static void printA(int N, String[][] a, int i,int j,int rowEnd,int colEnd) {
int startCol =j;
int startRow =i;
for(;j<colEnd;j++)
{
System.out.print(a[i][j]);
}
i++;
for(;i<rowEnd;i++)
{
System.out.print(a[i][colEnd-1]);
}
j = colEnd-2;
i=rowEnd-1;
for(;j>startCol;j--)
{
System.out.print(a[i][j]);
}

for(;i>startRow;i--)
{
System.out.print(a[i][j]);
}
}

}

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

package com.adobe.test;

public class MatrixPrint {

public static void main(String[] args)
{


String[][] a = { {"i", "l", "o", "v", "e"}, {"d", "i", "n", "t", "e"}, {"n", "e", "w", "e", "p"}, {"a", "i", "v", "r", "i"},{"m", "a", "x", "e", "c"}};
int N = a.length;
int i=0;
int j=0;
int rowEnd = N;
int colEnd = N;
do{
printA(N, a,i,j,rowEnd,colEnd);
N = N-2 ;
i =i+1;
j= j+1;
rowEnd = rowEnd-1;
colEnd =colEnd-1;
}while (N >=1);
}

private static void printA(int N, String[][] a, int i,int j,int rowEnd,int colEnd) {
int startCol =j;
int startRow =i;
for(;j<colEnd;j++)
{
System.out.print(a[i][j]);
}
i++;
for(;i<rowEnd;i++)
{
System.out.print(a[i][colEnd-1]);
}
j = colEnd-2;
i=rowEnd-1;
for(;j>startCol;j--)
{
System.out.print(a[i][j]);
}

for(;i>startRow;i--)
{
System.out.print(a[i][j]);
}
}

}

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

public class CareerCup {

public static void printSpiral(int ar[][]){
printSpiral(ar,0,0,ar.length);
}


private static void printSpiral(int[][] ar, int startX, int startY, int currentRowColLength) {
// TODO Auto-generated method stub
if(currentRowColLength==startX)
return;
if(currentRowColLength-startX==1){
System.out.println(ar[startX][startY]);
return;
}

int i = startX;
int j=startY;

while(j<currentRowColLength){
System.out.print(ar[i][j]+" ");
j++;
}

i=i+1; j=j-1;

while(i<currentRowColLength){
System.out.print(ar[i][j]+" ");
i++;
}

i=i-1;j=j-1;

while(j>=startY){
System.out.print(ar[i][j]+" ");
j--;
}

j=j+1; i=i-1;

while(i>startX){
System.out.print(ar[i][j]+" ");
i--;
}
printSpiral(ar, startX+1, startY+1, currentRowColLength-1);
}


public static void main(String args[]){
int grid[][] = {{1,2,3,4},{12,13,14,5},{11,16,15,6},{10,9,8,7}};
int grid2[][] = {{1,2,3,4,5},{16,17,18,19,6},{15,24,25,20,7},{14,23,22,21,8},{13,12,11,10,9}};
CareerCup.printSpiral(grid2);
}
}

- Anonymous June 09, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<stdio.h>
#define n 5
int main()
{
	char a[n][n]={'i','l','o','v','e',
				'd','i','n','t','e',
				'n','e','w','e','p',
				'a','i','v','r','i',
				'm','a','x','e','c'};
	int i,j,k;
	for (i=0;i<=n/2;i++)
	{
		for (j=i;j<=n-i-1;j++)
		{
			printf ("%c",a[i][j]);
		}
		j=n-i-1;
		for (k=i+1;k<=n-i-1;k++)
		{
			printf ("%c",a[k][j]);
		}
		k=n-i-1;
		for (j=n-i-2;j>=i;j--)
		{
			printf ("%c",a[k][j]);
		}
		j=i;
		for (k=n-i-2;k>=i+1;k--)
		{
			printf ("%c",a[k][j]);
		}
	}
	return 0;
}

- Jitendra June 22, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

perfect code!! I thought of same logic :P

- abc November 14, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

typedef enum State
{
	colInc,
	lineInc,
	colDec,
	lineDec
}state;

char array [5] [5]=
	{
		"ilove",
		"dinte",
		"newep",
		"aivri",
		"maxec"
	};

void spiralPrint()
{
	static state currState = colInc;
	static int currCol = -1;
	static int currLine = 0;

	static int maxCol = 5;
	static int maxLine = 5;

	int i;

	switch(currState % 4)
	{
		case colInc:
		{
			for(i = 0; i < maxCol; ++ i)
			{
				printf("%c", array[currLine] [++ currCol]);
			}
			-- maxLine;
		}
		break;

		case lineInc:
		{
			for(i = 0; i < maxLine; ++ i)
			{
				printf("%c", array[++ currLine] [currCol]);
			}
			-- maxCol;
		}
		break;

		case colDec:
		{
			for(i = 0; i < maxCol; ++ i)
			{
				printf("%c", array[currLine] [-- currCol]);
			}
			-- maxLine;
		}
		break;

		case lineDec:
		{
			for(i = 0; i < maxLine; ++ i)
			{
				printf("%c", array[-- currLine] [currCol]);
			}
			-- maxCol;
		}
		break;
	}

	++ currState;
	if(maxLine || maxCol)
		spiralPrint();
}

- torda.csaba June 23, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<stdio.h>
#include<stdlib.h>
int count=0;
void go_right(char arr[5][5],int row,int st,int end)
{
int i;
for(i=st;i<=end;i++)
{
printf("%2c",arr[row][i]);
count++;
}
}
void go_down(char arr[5][5],int col,int st,int end)
{
int i;
for(i=st;i<=end;i++)
{
printf("%2c",arr[i][col]);
count++;
}
}
void go_left(char arr[5][5],int row,int st,int end)
{
int i;
for(i=st;i>=end;i--)
{
printf("%2c",arr[row][i]);
count++;
}
}
void go_up(char arr[5][5],int col,int st,int end)
{
int i;
for(i=st;i>=end;i--)
{
printf("%2c",arr[i][col]);
count++;
}
}
int main()
{
char arr[5][5]={'i','l','o','v','e','d','i','n','t','e','n','e','w','e','p','a','i','v','r','i','m','a','x','e','c'};
int pos=0,st=0,end=4;
while(1)
{
go_right(arr,pos,st,end);
if(count==25)
break;
go_down(arr,end,pos+1,end);
if(count==25)
break;
go_left(arr,end,end-1,pos);
if(count==25)
break;
go_up(arr,pos,end-1,pos+1);
if(count==25)
break;
pos++;
st++;
end--;
}
}

- coolanand June 30, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<stdio.h>

int main()
{

char a[5][5]={'i' ,'l' ,'o' ,'v' ,'e' ,
'd' ,'i' ,'n' ,'t' ,'e' ,
'n' ,'i' ,'e' ,'e' ,'p' ,
'a' ,'v' ,'w' ,'r' ,'i' ,
'm', 'a' ,'x' ,'e' ,'c'};
int i,j,count=0,mini=0,minj=-1,maxj=4,maxi=4;

do{

if(count%2==0)
{
for(j=++minj;j<=maxj;j++)
printf("%c",a[mini][j]);
for(i=++mini;i<=maxi;i++)
printf("%c",a[i][maxj]);
}
else
{
for(j=--maxj;j>=minj;j--)
printf("%c",a[maxi][j]);
for(i=--maxi;i>=mini;i--)
printf("%c",a[i][minj]);
}

count++;
}while(count<5);

return 0;
}

- Harshil Raval July 01, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<stdio.h>

void printSpiral(char [5][5],int);
int main(){
int num,i=0,j=0;

char arr[5][5]={{'i','l','o','v','e'},{'d','i','n','t','e'},{'n','e','w','e','p'},{'a','i','v','r','i'},{'m','a','x','e','c'}};

fflush(stdin);

printSpiral(arr,5);
return 0;


}

void printSpiral(char arr[5][5],int num){
int round = 0, end = num-1,j=0;
for(round=0;round<=num/2;round++){
for(j=round;j<=end;j++)
printf("%c",arr[round][j]);
for(j= round+1;j<=end;j++)
printf("%c",arr[j][end]);
for(j=end-1;j>=round;j--)
printf("%c",arr[end][j]);
for(j = end-1;j>=round+1;j--)
printf("%c",arr[j][round]);

end--;

}

}

- Anonymous August 12, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

In Python 3.x

def matrix_spiral(matrix):
	max_index = len(matrix)
	spiral_order = []
	from math import floor
	max_offset = floor(max_index/2)

	for offset in range(0, max_offset):
		spiral_order = spiral_order + [matrix[offset][col_index] for col_index in range(offset, max_index - offset)]
		spiral_order = spiral_order + [matrix[row_index][max_index - offset - 1] for row_index in range(offset + 1, max_index  - offset - 1)]
		spiral_order = spiral_order + [matrix[max_index - offset - 1][col_index] for col_index in range(max_index - offset -1, offset - 1, -1)]
		spiral_order = spiral_order + [matrix[row_index][offset] for row_index in range(max_index - offset - 2, offset, -1)]

	if max_offset != max_index / 2:
		spiral_order = spiral_order + [ matrix[max_offset][max_offset] ]

	return spiral_order

k=[ ['i', 'l', 'o', 'v','e'], 
['d', 'i', 'n', 't', 'e'], 
['n', 'e', 'w', 'e', 'p'], 
['a', 'i', 'v', 'r', 'i'], 
['m', 'a', 'x', 'e', 'c'] ]

print(matrix_spiral(k))

- ParokshaX August 13, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public class spiralDisplay{
static void spiralDisplay(char[][] cmatrix){
int length=cmatrix.length;
System.out.println(length/2);
for(int count=0;count<length/2+1;count++){
for(int i=count;i<length-count-1;i++){System.out.print(cmatrix[count][i]);}
for(int i=count;i<length-count-1;i++){System.out.print(cmatrix[i][length-count-1]);}
for(int i=length-count-1;i>count;i--){System.out.print(cmatrix[length-count-1][i]);}
for(int i=length-count-1;i>count;i--){System.out.print(cmatrix[i][count]);}
}
if(length%2==1){System.out.print(cmatrix[length/2][length/2]);}
}
public static void main(String[] args){
final char[][] charArray =
{
{'i', 'l', 'o', 'v', 'e' },
{'d', 'i', 'n', 't', 'e' },
{'n', 'e', 'w', 'e', 'p' },
{'a', 'i', 'v', 'r', 'i' },
{'m', 'a', 'x', 'e', 'c' }
};
spiralDisplay.spiralDisplay(charArray);
}
}

- java September 08, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

///
#include <stdio.h>

int main(void)
{
int m=5,n=5;
char ch[5][5]={{'i','l','o','v','e'},{'d','i','n','t','e'},{'n','e','v','e','p'},{'a','i','v','r','i'},{'m','a','x','e','c'}};
int x=m*n;
int i=0,j=0;
int cs=0;
int lowi=0,lowj=0;
while(x--)
{
printf("%c",ch[i][j]);
switch(cs)
{
case 0:
{
if(j==n-1)
{
cs=1;
lowi++;
if(i<m)
i++;
}
else if(j<n-1)
j++;
break;
}
case 1:
{
if(i==m-1)
{
cs=2;
n--;
if(j>lowj)
j--;
}
else if(i<n-1)
i++;
break;
}
case 2:
{
if(j==lowj)
{
m--;
cs=3;
if(i>lowi)
i--;
}
else if(j>lowj)
j--;
break;
}
case 3:
{
if(i==lowi)
{
lowj++;
cs=0;
if(j<n)
j++;
}
else if(i>lowi)
i--;
break;
}
}
}
return 0;
}
\\\

- Anon October 09, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include <stdio.h>

int main(void)
{
	int m=5,n=5;
	char ch[5][5]={{'i','l','o','v','e'},{'d','i','n','t','e'},{'n','e','v','e','p'},{'a','i','v','r','i'},{'m','a','x','e','c'}};
	int x=m*n;
	int i=0,j=0;
	int cs=0;
	int lowi=0,lowj=0;
	while(x--)
	{
		printf("%c",ch[i][j]);
		switch(cs)
		{
			case 0:
			{
				if(j==n-1)
				{
					cs=1;
					lowi++;
					if(i<m)
						i++;
				}
				else if(j<n-1)
					j++;
				break;
			}
			case 1:
			{
				if(i==m-1)
				{
					cs=2;
					n--;
					if(j>lowj)
						j--;
				}
				else if(i<n-1)
					i++;
				break;
			}
			case 2:
			{
				if(j==lowj)
				{
					m--;
					cs=3;
					if(i>lowi)
						i--;
				}
				else if(j>lowj)
					j--;
				break;
			}
			case 3:
			{
				if(i==lowi)
				{
					lowj++;
					cs=0;
					if(j<n)
						j++;
				}
				else if(i>lowi)
					i--;
				break;
			}
		}
	}
	return 0;
}

- Anon October 09, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public class Test {

    private static char[][] matrix = {    
		{'i',	'l', 	'o', 	'v', 	'e' },
		{'d',	'i', 	'n', 	't', 	'e' },
		{'n', 	'e', 	'w', 	'e', 	'p' }, 
		{'a', 	'i', 	'v', 	'r', 	'i' }, 
		{'m',	'a', 	'x', 	'e', 	'c' } };
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		int N = matrix.length;
		int i=0, j=0;
		for (int layer = 0; layer < N/2; layer++) {
			i = layer;
			for (j = layer; j < N-1-layer; j++) {
				System.out.print(matrix[i][j]);
			}
			
			j = N - 1 - layer;
			for (i = layer; i < N-1-layer; i++) {
				System.out.print(matrix[i][j]);
			}
			
			i = N - 1 - layer;
			for (j = N-1-layer; j > layer; j--) {
				System.out.print(matrix[i][j]);
			}
			
			j = layer;
			for (i = N-1-layer; i > layer; i--) {
				System.out.print(matrix[i][j]);
			}
		}
		if (N % 2 != 0) {
			System.out.print(matrix[N/2][N/2]);
		}
	}

}

- vaticanoptimist October 09, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Nice!!

- xyz November 14, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

private void printMatrixSpiral(final char[][] m, final int l, final int r) {

		if (l>r) {
			return;
		} else if (l==r) {
			System.out.print(m[l][l]);
		} else {
			for (int i = l; i<= r-1; i++) {
				System.out.print(m[l][i]);
			}
			for (int j = l; j<= r-1 ; j++) {
				System.out.print(m[j][r]);
			}
			for (int k = r; k>=l+1 ; k--) {
				System.out.print(m[r][k]);
			}
			for (int g = r; g>=l+1 ; g--) {
				System.out.print(m[g][l]);
			}
			printMatrixSpiral(m, l+1, r-1);
		}

- amd October 19, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include <stdio.h>
#include <string.h>

void printSpiral(char **mat, int P, int Q) {
	int j = 0;
	int start = 0;

	while(start < P || start < Q){
		for(j = start ; j < P ; ++j) printf("%c", mat[start][j]);
		for(j = start+1 ; j < Q-1 ; ++j) printf("%c", mat[j][P-1]);
		if(Q-1 != start) {
			for(j = P-1 ; j >= start ; j--) printf("%c", mat[Q-1][j]);
		}
		if(P-1 != start) {
			for(j = Q-2 ; j >= start+1 ; j--) printf("%c", mat[j][start]);
		}
		start++;
		P--;
		Q--;
	}
}
int main() {
	char *mat[] = {"ilov#e", "dint#e", "newe#p", "aivr#i", "maxe#c"};
	/*
	i l o v # e
	d i n t # e
	n e w e # p
	a i v r # i
	m a x e # c

	ilov#eepic#examandint###rviewe
	*/
	
	printSpiral(mat, strlen(mat[0]), sizeof(mat)/sizeof(mat[0]));
	printf("\n");
	return 0;

}

- abhi November 17, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public ArrayList<Integer> spiralOrder(int[][] matrix) {
        // Start typing your Java solution below
        // DO NOT write main() function
        ArrayList<Integer> result = new ArrayList<Integer>();
        if(matrix.length==0||matrix[0].length==0)
        return result;
        spiralOrderHelper(matrix, result, 0, 0, matrix.length-1, matrix[0].length-1);
        return result;
    }
    private void spiralOrderHelper(int[][] matrix, ArrayList<Integer> result, int rs, int cs, int re, int ce) {
        if(rs>re||cs>ce)
        return;
        if(re==rs) {
            for(int i=cs; i<=ce; i++) {
                result.add(matrix[rs][i]);
            }
            return;
        }
        if(ce==cs) {
            for(int i=rs; i<=re; i++) {
                result.add(matrix[i][cs]);
            }
            return;
        }
        for(int i=cs; i<=ce; i++) {
            result.add(matrix[rs][i]);
        }
        for(int i=rs+1; i<=re; i++) {
            result.add(matrix[i][ce]);
        }
        for(int i=ce-1; i>=cs; i--) {
            result.add(matrix[re][i]);
        }
        for(int i=re-1; i>rs; i--) {
            result.add(matrix[i][cs]);
        }
        spiralOrderHelper(matrix, result, rs+1, cs+1, re-1, ce-1);
    }

- sz2376@columbia.edu December 01, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public static void main(String[] args) {

		char[][] matrix = {     {'i', 'l', 'o', 'v', 'e' },
						 {'d', 'i', 'n', 't', 'e' },
						 {'n', 'e', 'w', 'e', 'p' }, 
						 {'a', 'i', 'v', 'r', 'i' }, 
						 {'m', 'a', 'x', 'e', 'c' } };

		PrintSpiral(matrix);

	}
	
	public static void PrintSpiral( char[][] matrix ) {

		int level = 0;
		int N = matrix.length;
		int i, j;

		while ( level < N-level ) {

			i = level;
			j = level;

			//Print top row
			while ( i < N-level)
				System.out.print(matrix[j][i++]);
			i--;
			j++;

			//Print right column
			while ( j < N-level)
				System.out.print(matrix[j++][i]);
			j--;
			i--;

			//Print bottom row
			while ( i >= level)
				System.out.print(matrix[j][i--]);
			i++;
			j--;

			//Print left column, avoid duplicate of first char in level
			while ( j >= level + 1)
				System.out.print(matrix[j--][i]);

			level++;

		}

	}

- tp December 23, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

INPUT:
First line contains two integers M and N separated by whitespace. The next M lines contain elements of matrix A, starting with the topmost row. Within each row, the elements are given from left to right.

OUTPUT:
Elements of the matrix printed in a spiral order. All the elements should be separated by whitespace.

CONSTRAINTS:
1 <= M <= 5, 1 <= N <= 5.
Elements in the matrix will be in the range [-100,100]
give program for this conditions any one

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

#include <iostream>
using namespace std;

void print_spiral(char a[5][5],int n)
{
int count =n*n;
int i=0;
int j=0;
int start =0;
while(count>0)
{
while(j<n)
{
cout<<a[i][j]<<" ";
j++;
count--;
}
j=n-1;
i = i+1;
while(i<n)
{
cout<<a[i][j]<<" ";
i++;
count--;
}
i=n-1;
j= n-2;
while(j>start)
{
cout<<a[i][j]<<" ";
j--;
count--;
}
j= start;
while(i>start)
{
cout<<a[i][j]<<" ";
i--;
count--;
}
start = start+1;
i= start;
j= start;
n=n-1;
}
}

int main() {
// your code goes here
char matrix[5][5] = { 'i', 'l', 'o', 'v', 'e',
'd', 'i', 'n', 't', 'e',
'n', 'e', 'w', 'e', 'p',
'a', 'i', 'v', 'r', 'i',
'm', 'a', 'x', 'e', 'c',
};
print_spiral(matrix,5);
return 0;
}

- Anonymous August 30, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

This is for Java

public void printSpiralMatrix() {
		int col = 0;
		int row = 0;
		//first row: separate loop
		for (; col < MATRIX_SIZE; col++) {
			System.out.print(matrix[row][col]);
		}
		col--;
		for (int n = MATRIX_SIZE - 1; n > 0; n--) {
			int colInc = (col - 1) > 0? -1 : 1;
			int rowInc = (row - 1) > 0? -1 : 1;
			int i = 0;
			do {
				row += rowInc;
				System.out.print(matrix[row][col]);
				i++;
			} while (i < n);
			
			i = 0;
			do {
				col += colInc;
				System.out.print(matrix[row][col]);
				i++;
			} while (i < n);
		}
	}

- Yang October 23, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

So many "for"s and "if-else"... Just name a counter and follow the spiral path until the counter reaches n**2. That's it! btw, the input is wrong. Should use { "ilove", "dinte", "newep", "aivri", "maxec" }.

Playable code at:

ideone.com/sqWl30

pair<int, int> nextdir(pair<int, int> dir) {
	if (dir == pair<int, int>{0, 1}) return pair<int, int>{1, 0};
	else if (dir == pair<int, int>{1, 0}) return pair<int, int>{0, -1};
	else if (dir == pair<int, int>{0, -1}) return pair<int, int>{-1, 0};
	else return pair<int, int>{0, 1};
}

vector<char> spiral(vector<string> matrix) {
	vector<char> ret;
	if (matrix.size() <= 0) return ret;

	int row(0), col(0);
	pair<int, int> dir{ 0, 1 };
	for (int i = 0; i < matrix.size()*matrix.size(); ++i) {
		ret.push_back(matrix[row][col]);
		matrix[row][col] = 0;	// dont forget this
		row += dir.first; col += dir.second;
		if (row < 0 || col < 0 || row == matrix.size() || \
			col == matrix.size() || !matrix[row][col]) {
			row -= dir.first; col -= dir.second;
			dir = nextdir(dir);
			row += dir.first; col += dir.second;
		}
	}

	return ret;
}

- XiaoPiGu December 13, 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