## Matrix Placement Papers

Matrix Technical JAVA Paper

## Placement Papers for All Companies

3i infotech

Abacus Infotech

Abatix

Abaxis

ABB

ACC Limited

Accel Frontline

Accenture

Aditi Technologies

Adobe System

ADP

Agilysys

AgreeYa

AIG

AirNet

Alanco Technologies

Alle Technologies

Allfon

Alter Systems

Amazon

AMDL

Amdocs

AMI

Amiti Software Technologies

ANZ

Apple

Applied Materials

Apps Associates

Aricent

ASDC

Ashok Leyland Ltd

Asian Paints

Aspire System

AT & T

Atlas Copco

Atos Origin

AXA Technology Services

Axes Technology

Bain

Bajaj

Bayer

Bharti Airtel Ltd

Bhawan Cybertek

Birlasoft

Blue Star Infotech

BMC

BOB

Brakes India

C-DOT

CA Technologies

Cadence

Calsoft

Canarys

Capgemini

Caterpillar

Celstream

CGI Group

Changepond Technologies

Cimtrix Systems

Cisco system

Citicorp Overseas Software Ltd

ClinTech

CMC Limited

CMS

Cognizant

Compaq

Consagous Technologies

Convergys

CORDYS

CRISIL

Crompton Greaves

CSC

CSFB

CtrlS Datacenters Ltd

Cummins

Cyient

Daffodil

Daimler

Dell

Deloitte

Delphi-TVS

Dharma Systems

Directi

DSRC

Eicher

ELGI

ELICO

EMC Corporation

Emphasis

Ericsson

Ernst & Young

ESKO

Essar

Facebook

Fanuc Corporation

Fidelity

Flextronics

Flipkart

Freescale

Fujitsu

Gajshield

GE

Genpact India

Geodesic

Geometric Limited

GlobalEdge

GlobalLogic

GMR Group

Godrej Infotech

Google

Grapecity

Harita - TVS

HCL

HCL Technologies

Headstrong

Healthasyst

HEC Ltd

Hexaware

HFCL

Holool

Honeywell

HP

HTC Global Services

Huawei

Hughes

Hyundai

IBM

IBS Software Services

IGate

Ikanos

IKOS

Impetus

iNautix

Indecomm

IndiaBulls Power Limited

Inductis-EXL

Industrial Alliance

Infineon

Infogain

Infosys

Intec

Integra

Intel

Intergraph

ITC Infotech

Jindal Steel and Power Limited

KPIT

L & T

L & T Infotech

LG Soft

Linde India Ltd

LnT Emsys

LnT-ECC

Lucas - TVS

Mahindra Engineering Services Ltd

Mahindra Ltd

Maruti

Matrix

Maveric Systems

McAfee

Microland

Microsoft

Mindtree

Miraclesoft

MKCL

Motorola

Mu-Sigma

Nagarro

NASSCOM

NCR Corporation

Ness Technologies

Neudesic

NIIT Technologies

Novell

Nvidia

Oracle

Persistent

Philips

Planetasia

Polaris

Poornam Info Vision

PSI Data Systems Limited

Quest-Global

Quinnox

R Systems

Redpine

Reliance Energy

Robert Bosch

RS Software

Samsung

SAP labs India

Sapient

Sasken Communications

Schneider India

Serco

Siemens

Sierra Atlantic

SkyTECH

Soliton

Sonata Software

Sony India

SQL Star

Steria

Subex Limited

Sutherland Global Services

Syntel

Talisma

Tata motors

Tata technologies

Tata-ELXSI

TCE

TCS

Tech Mahindra

Temenos

Tesco

Texas Instruments

Thermax

ThoughtWorks

Torry Harris

Triad

Trianz

Trilogy

TVS Motor

Unisys

UnitedHealth Group

UST Global

UTC Aerospace System

Valuelabs

Vedanta

Verifone

Verizon

Virtusa

Vision Infotech

Vizual

VMware

Wipro

Yahoo

YASH Technologies

Zenith

Zensar Technologies

ZTE

# Matrix Interview Questions

Posted on :06-04-2016

**Q1. Given a 2D array of digits, try to find the occurrence of a given 2D pattern of digits. For example, consider the following 2D matrix:**

7283455864

6731158619

8988242643

3839505324

9509505813

3843845384

6473530293

7053106601

0834282956

4607924137

Assume we need to look for the following 2D pattern:

950

384

353

**Q2.**Allocate a 2-D array of size m*n using malloc(). The array should be accessible as a[i][j].

**Q3. You are tasked with defining and implementing a function. as input, you are given an n x m matrix. x may appear any number of times in a matrix. your function should modify the b matrix such that any row and column where x originally appears are completely over written with x**

For example:

- - - - -

- - - - -

- - - x -

x - - - -

- - - - -

Expected output:

x - - x -

x - - x -

x x x x x

x x x x x

x - - x -

**Q4.**Write a function to print unique rows of a matrix.

**Q5.**Write a utility function that takes the starting position (P0) and length (L0) of one line segment plus the start position (P1) and length (L1) of a second line segment and returns the configurations where both segments end at the same point. Both starting points can be anywhere in three dimensional space.

**Q6. A 2D matrix is given to you. Now user will give 2 positions (x1,y1) and (x2,y2), which is basically the upper left and lower right coordinate of a rectangle formed within the matrix. You have to print sum of all the elements within the area of rectangle in O(1) running time. Now you can do any pre computation with the matrix. But when it is done you should answer all your queries in constant time.**

Example : consider this 2D matrix

1 3 5 1 8

8 3 5 3 7

6 3 9 6 0

Now consider 2 points given by user (0, 2) and (2, 4).

Your solution should print: 44.

i.e., the enclosed area is

5 1 8

5 3 7

9 6 0

**Q7. Given is a matrix arr[n][n], find a submatrix sub[m][m] such summation of all the elements in submatrix is maximum.**

Given condition,

1. m <= n

2. m >= 2

3. consider positive, negavive and zero integers in arr[n][n]

4. User provide n.

**Q8. Search in a row wise and column wise sorted matrix.**

**Q9. Write a code to read and write a matrix in below given way.**

**Note : no. indicates the sequence here.**

I/P

1 2 3

4 5 6

7 8 9

O/P

1 6 7

2 5 8

3 4 9

**Q10. Given an n x n matrix A(i,j) of integers, find maximum value A(c,d) - A(a,b) over all choices of indexes such that both c > a and d > b.**

**Required complexity: O(n^2)**

**Q11. String [] [] matrix = {{"A","N", "L", "Y", "S"},{"I", "S", "D", "E", "S"},{"I", "G", "N", "D", "E"}};**

2. Given a word "DES"

3. Write a program to find the occurences of this word "DES". Letters must be next to each other in the matric.

4. "Next" means: left, right, up, down, left down, right down, upper left, upper right

5.. For example: S at (1,1): A, N, L, D, N, G, I, I are next to S at (1,1)

Required output

// // D - [1, 2], E - [1, 3], S- [1, 4]

// D - [1, 2], E - [1, 3], S- [0, 4]

// D - [2, 3], E - [2, 4], S - [1, 4]

// D - [2, 3], E - [1, 3], S - [0, 4]

// D - [2, 3], E - [1, 3], S - [1, 4]

**Q12. Given an NxM (N rows and M columns) integer matrix with non-negative values (0..MAX_INT inclusive). What is the maximum sum from going top left (0, 0) to bottom right (N-1, M-1) ? The condition is that when youre at point (p, q), you can only move to either right (p, q+1) or down (p+1, q).**

Expected time complexity O(N*M)

Expected space complexity O(N+M)

**Q13. There is a binary tree of size N. All nodes are numbered between 1-N(inclusive). There is a N*N integer matrix Arr[N][N], all elements are initialized to zero. So for all the nodes A and B, put Arr[A][B] = 1 if A is an ancestor of B (NOT just the immediate ancestor).**

**Q14.**We are given a matrix of MxN elements with each element either being 0 or 1.Find the shortest path between a given source cell to a destination cell.

An element value of 0 means we cannot create a path out of that cell.

**Q15. Consider there are n matrices. For eg, A, B, C and D are four matrices. Find the groupings of matrices during their product, the operations involved in your choice of grouping is minimal.**

For eg, you can group like (AB)CD or (ABC)D or A(BC)D or A(BCD) .... But among these options in which grouping the operations of matrix multiplication will be minimal. Remember in matrix multiplication , multiplication and sum of elements are involved.

**Q16. Given a matrix of 0s and 1s find the number of groups of 1s in the matrix.**

**A group of 1s can be formed if a 1 is present either vertically or horizontally to the adjacent 1 and not diagonally.**

1 0 0 0

1 1 0 0

0 0 1 1

0 0 1 1

The above matrix has two groups of 1s while the one shown here has only one group

1 1 0 0

1 1 1 0

1 1 0 0

No restrictions on space complexity was given but the interviewer did mention that the time complexity should be efficient and that it should work for extremely large matrixs as well.

**Q17**. Given a m * n matrix and value k. Find k * k matrix within the given matrix whose sum is maximum.

**Q18.**Search a number in a large square but sorted matrix. Since the matrix can be very large, keep algorithmic efficiency in mind.

**Q19. "Min(Max elements rows) not less than Max(Min of columns)"**

**can you tell me whether above statement ist true or false..**

**if it true, then tell me solutoin.**

**if it false, then tell me example**

**Q20. In a nxn matrix, data provided like below. We need to find the groups of 1s with the adjus**

**ent column and row.**

(eg)

0 0 0 0

1 1 1 1

0 0 0 0

group of 1 is 1

1 0 0 0

0 0 0 1

1 1 0 0

group of 1s is 3

Any thought how to get the set of groups.

**Q21. Given a binary matrix of N X N of integers , you need to return only unique rows of binary arrays**

eg:

0 1 0 0 1

1 0 1 1 0

0 1 0 0 1

1 1 1 0 0

__ANS:__0 1 0 0 1

1 0 1 1 0

1 1 1 0 0

**Q22. Given a number n... print a spiral matrix in O(1) space example if n=5 the op should be:**

25 24 23 22 21

10 09 08 07 20

11 02 01 06 19

12 03 04 05 18

13 14 15 16 17

The question may appear trivial but its not...you have to print in O(1) space

## Matrix Placement Papers

➤ Matrix Technical JAVA Paper

## Top Companies Placement Papers

TCS Papers

Wipro Papers

HCL Papers

IBM Papers

Amazon Papers

CISCO System Papers

Cognizant Papers

CSC Papers

Tata Motors Papers

Tech Mahindra Papers

L&T Papers

Facebook Papers

Dell Papers

L & T Infotech Papers

Capgemini Papers

HP Papers

Microsoft Papers

Google Papers

Samsung Papers