Browser tab content: Problem List 0 Debugging... Run Submit 00:00:00 Description…
- User
Browser tab content: Problem List 0 Debugging... Run Submit 00:00:00 Description Editorial Editorial Solutions Solutions Submissions Submissions Code Note Note Testcase Testcase Test Result 311. Sparse Matrix Multiplication Medium Topics Companies
Given two sparse matrices mat1 of size m x k and mat2 of size k x n, return the result of mat1 x mat2. You may assume that multiplication is always possible.
Example 1:
Input: mat1 = [[1,0,0],[-1,0,3]], mat2 = [[7,0,0],[0,0,0],[0,0,1]] Output: [[7,0,0],[-7,0,3]]
Example 2:
Input: mat1 = [[0]], mat2 = [[0]] Output: [[0]]
Constraints:
m == mat1.length k == mat1[i].length == mat2.length n == mat2[i].length 1 <= m, n, k <= 100 -100 <= mat1[i][j], mat2[i][j] <= 100 Seen this question in a real interview before? 1/5 Yes No Accepted 197.1K Submissions 288.3K Acceptance Rate 68.4% Topics Array Hash Table Matrix Companies 0 - 6 months LinkedIn 3 Meta 2 Bloomberg 2 6 months ago Pinterest 6 Apple 2 Cruise 2 Discussion (7) Choose a type Preview Comment 💡 Discussion Rules
-
Please don't post any solutions in this discussion.
-
The problem discussion is for asking questions about the problem or for sharing tips - anything except for solutions.
-
If you'd like to share your solution for feedback and ideas, please head to the solutions tab and post it there.
Sort by:Best No comments yet. 1 Copyright ©️ 2024 LeetCode All rights reserved 1.1K 7 Java Auto 1 2 3 4 5 class Solution { public int[][] multiply(int[][] mat1, int[][] mat2) { } } Saved Ln 1, Col 1 You must run your code first
Counting Bits - LeetCode
Problem List Tag 237. Delete Node in a Linked List
Med.
- Product of Array Except Self
Med.
- Sliding Window Maximum
Hard
- Search a 2D Matrix II
Med.
- Different Ways to Add Parentheses
Med.
- Valid Anagram
Easy
- Shortest Word Distance
Easy
- Shortest Word Distance II
Med.
- Shortest Word Distance III
Med.
- Strobogrammatic Number
Easy
- Strobogrammatic Number II
Med.
- Strobogrammatic Number III
Hard
-
- Assistant
Sure, I'll extract the relevant information and provide a Java solution for the problem.
Problem: Sparse Matrix Multiplication
You're given two sparse matrices
mat1of sizem x kandmat2of sizek x n. You need to return the result of multiplyingmat1withmat2. You can assume that the multiplication is always possible.