Coding Interview Club

Prepare for coding interviews in simple and structured steps

Important Problems on Arrays

Problem: 
  1. Find all pairs of integers within an array that sum to a specified value:
    • Approach 1: Using hash table (more time efficient)
    • Approach 2: Through sorting (more space efficient)
  2. Given an M x N matrix, if an element is 0, its entire row and column in the matrix should be set to 0.
  3. You are given a 2-Dimensional array (matrix) and a scale factor. You need to write a method to scale the 2D array according to the scale factor.
    1. The signature of the method should be 
      1. public static int[][] scale1(int[][] arr, int scale)
    2. Example: if you are given a 2*3 array and scale factor is 3, the output array will be 6*9; the input and output arrays will be as follows:
      • Input
        • 1 2 3 
        • 4 5 6 
      • Output
        • 1 1 1 2 2 2 3 3 3 
        • 1 1 1 2 2 2 3 3 3 
        • 1 1 1 2 2 2 3 3 3 
        • 4 4 4 5 5 5 6 6 6 
        • 4 4 4 5 5 5 6 6 6 
        • 4 4 4 5 5 5 6 6 6 
Solution: 

Refer to individual problems under corresponding problem category for solutions.

Back to Top