Pairwise Sums
Return a 2-D array with len(a) rows and len(b) columns, where the cell at row i, column j is a[i] + b[j]. Hint: turn a into a column with a.reshape(-1, 1) and let broadcasting do the rest.
Example 1
a [1,2]
b [10,20,30]
returns [[11,21,31],[12,22,32]]
Row 0 is [11, 21, 31] and row 1 is [12, 22, 32].
Constraints
1 <= len(a), len(b) <= 10
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More NumPy problems
- Path LengthMedium
- Rank of Each ScoreMedium
- Ranks Without GapsMedium
- Record HighsMedium
- Risk of a MixMedium
- Row SharesMedium
- Sort by First ColumnMedium
- Subtract Row MinimumMedium