Skip to content

Commit 690e831

Browse files
committed
Add solution #867
1 parent 748355c commit 690e831

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
819|[Most Common Word](./0819-most-common-word.js)|Easy|
3333
824|[Goat Latin](./0824-goat-latin.js)|Easy|
3434
831|[Masking Personal Information](./0831-masking-personal-information.js)|Medium|
35+
867|[Transpose Matrix](./0867-transpose-matrix.js)|Easy|
3536
890|[Find and Replace Pattern](./0890-find-and-replace-pattern.js)|Medium|
3637
916|[Word Subsets](./0916-word-subsets.js)|Medium|
3738
929|[Unique Email Addresses](./0929-unique-email-addresses.js)|Easy|

solutions/0867-transpose-matrix.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* 867. Transpose Matrix
3+
* https://leetcode.com/problems/transpose-matrix/
4+
* Difficulty: Easy
5+
*
6+
* Given a matrix A, return the transpose of A.
7+
*
8+
* The transpose of a matrix is the matrix flipped over it's main
9+
* diagonal, switching the row and column indices of the matrix.
10+
*/
11+
12+
/**
13+
* @param {number[][]} A
14+
* @return {number[][]}
15+
*/
16+
var transpose = function(A) {
17+
return A[0].map((_, i) => A.map(j => j[i]));
18+
};

0 commit comments

Comments
 (0)