{"id":238,"date":"2018-11-15T20:48:43","date_gmt":"2018-11-15T12:48:43","guid":{"rendered":"https:\/\/www.ccagml.com\/?p=238"},"modified":"2018-11-29T14:49:24","modified_gmt":"2018-11-29T06:49:24","slug":"867-transpose-matrix","status":"publish","type":"post","link":"https:\/\/www.ccagml.com\/?p=238","title":{"rendered":"867. Transpose Matrix"},"content":{"rendered":"<p>Given a\u00a0matrix\u00a0<code>A<\/code>, return the transpose of\u00a0<code>A<\/code>.<\/p>\n<p>The transpose of a matrix is the matrix flipped over it&#8217;s main diagonal, switching the row and column indices of the matrix.<\/p>\n<p>&nbsp;<\/p>\n<div>\n<p><strong>Example 1:<\/strong><\/p>\n<pre><strong>Input: <\/strong><span id=\"example-input-1-1\">[[1,2,3],[4,5,6],[7,8,9]]<\/span>\r\n<strong>Output: <\/strong><span id=\"example-output-1\">[[1,4,7],[2,5,8],[3,6,9]]<\/span>\r\n<\/pre>\n<div>\n<p><strong>Example 2:<\/strong><\/p>\n<pre><strong>Input: <\/strong><span id=\"example-input-2-1\">[[1,2,3],[4,5,6]]<\/span>\r\n<strong>Output: <\/strong><span id=\"example-output-2\">[[1,4],[2,5],[3,6]]<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>Note:<\/strong><\/p>\n<ol>\n<li><code>1 &lt;= A.length\u00a0&lt;= 1000<\/code><\/li>\n<li><code>1 &lt;= A[0].length\u00a0&lt;= 1000<\/code><\/li>\n<\/ol>\n<\/div>\n<\/div>\n<p><strong>Python<\/strong><\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\"> \r\nclass Solution(object):\r\n    def transpose(self, A):\r\n        &quot;&quot;&quot;\r\n        :type A: List[List[int]]\r\n        :rtype: List[List[int]]\r\n        &quot;&quot;&quot;\r\n        L = [[] for i in range(len(A[0]))]\r\n        for a1 in A:\r\n            for k,v in enumerate(a1):\r\n                L[k].append(v)\r\n        return L\r\n        \r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Given a\u00a0matrix\u00a0A, return the transpose of\u00a0A. The transp<a href=\"https:\/\/www.ccagml.com\/?p=238\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">867. Transpose Matrix<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[29,20],"tags":[],"_links":{"self":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts\/238"}],"collection":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=238"}],"version-history":[{"count":1,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts\/238\/revisions"}],"predecessor-version":[{"id":239,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts\/238\/revisions\/239"}],"wp:attachment":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=238"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=238"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=238"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}