Array Interview Questions

Rotate matrix clockwise

Posted on

Problem statement – Given an array of N rows and N columns (square matrix), rotate the matrix by 90° in clockwise direction. Solution – This is an implementation based problem, which means that when asked in an interview, the interviewer is mainly testing your skill to write a program which follows some set of rules. […]

Array Interview Questions

Print matrix in spiral order

Posted on

Problem statement – Given a 2D array (or matrix) of N rows and M columns, print it in a spiral order. Example, for the below matrix – The output is – Solution – When an interviewer asks you this question, he/she is just testing your implementation skills. This question isn’t tough because it doesn’t have […]

Array Interview Questions

Add one to digit array

Posted on

Problem statement – Given a non-negative integer in the form of an array of digits, add one to digit array. The digits are stored such that the most significant digit is at the head of the list. Eg. – A = {1, 3, 5}, answer = {1, 3, 6} Solution – When an interviewer asks […]