ITeye博客

2019 年文章归档

共 2 篇文章

498. Diagonal Traverse

Given a matrix of M x N elements (M rows, N columns), return all elements of the matrix in diagonal order as shown in the below image. Input: [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] Output: [1,2,4,7,5,3,6,8,9] Solution: class Solution(object): def findDiagonalOrder(self, matrix): """ :type matrix…

2019-11-15 13:52 · 数据结构 · Leetcode

496 Next Greater Element I

You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nums1's elements in the corresponding places of nums2. The Next Greater Number of a number x in nums1 is the first greater number to its right in nums2. If…

2019-11-14 13:50 · Leetcode