Engineering Full Stack Apps with Java and JavaScript
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)
Given an M x N matrix, if an element is 0, its entire row and column in the matrix should be set to 0.
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.
The signature of the method should be
public static int[][] scale1(int[][] arr, int scale)
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