## varsrm

BAN USER
Questions (1)

Comments (2)

Reputation 15

- 0of 0 votes

AnswersIn a matrix of characters, find an string. String can be in any way (all 8 neighbors to be considered), like find Microsoft in below matrix.

- varsrm in United States

A-C-P-R-C

X-S-O-P-C

V-O-V-N-I

W-G-F-M-N

Q-A-T-I-T

String Microsoft is present in the matrix above ?

There also a slight variation where a diagonal neighbor is not considered.| Report Duplicate | Flag | PURGE

Microsoft Software Development Manager

**CareerCup**is the world's biggest and best source for software engineering interview preparation. See all our resources.

Open Chat in New Window

If the array list consists of all the numbers until n. Sum of all numbers including n would be n(n+1)/2. Now, we want to find 'a' subset whose sum is a multiple of n.

- varsrm November 13, 2014When n is odd, n+1 is even, hence, the sum of all the numbers including n would be a multiple of n. Hence, the answer here is a subset with all the numbers including n.

When n is even, sum of all even numbers until and including n is (n)(n+2)/2 which again is a multiple of n. Hence, the answer here is a subset with all the even numbers until and including n.

Same approach can be followed for multiples of 2N.