- 博客(6)
- 收藏
- 关注
原创 选择排序、插入排序、希尔排序
一、选择排序 SelectionSort思想找到数组中最小的那个元素,其次, 将它与数组的第一个元素交换位置(如果第一个元素就是最小元素那么它就和自己交换)。再次,在剩下的元素中找到最小的元素,将它与数组的第二个元素交换位置。如此往复,直到将整个数组排序。...
2021-01-20 18:32:29 114
原创 1480. Running Sum of 1d Array 一维数组的动态和
ProblemLeetcodeGiven an array nums. We define a running sum of an array as runningSum[i] = sum(nums[0]…nums[i]).Return the running sum of nums.ExampleInput: nums = [1,2,3,4]Output: [1,3,6,10]Explanation: Running sum is obtained as follows: [1, 1+2,
2021-01-19 21:40:50 91
原创 【Leetcode】 1232. Check If It Is a Straight Line 缀点成线
ProblemLeetcodeYou are given an array coordinates, coordinates[i] = [x, y], where [x, y] represents the coordinate of a point. Check if these points make a straight line in the XY plane.ExampleExample1Input: coordinates = [[1,2],[2,3],[3,4],[4,5],[5,
2021-01-17 14:41:41 97
原创 【Leetcode】 面试题 17.10. Find Majority Element LCCI 主要元素
ProblemLeetcodeA majority element is an element that makes up more than half of the items in an array. Given a positive integers array, find the majority element. If there is no majority element, return -1. Do this in O(N) time and O(1) space.ExampleEx
2021-01-16 16:54:59 129
原创 【Leetcode】 867. Transpose Matrix 转置矩阵
ProblemLeetcodeGiven a matrix A, return the transpose of A.The transpose of a matrix is the matrix flipped over it’s main diagonal, switching the row and column indices of the matrix.ExampleExample1:Input: [[1,2,3],[4,5,6],[7,8,9]]Output: [[1,4,7],
2021-01-16 15:26:01 93
原创 【Leetcode】 1672. Richest Customer Wealth 最富有客户的资产总量
ProblemLeetcodeYou are given an m x n integer grid accounts where accounts[i][j] is the amount of money the ith customer has in the jth bank. Return the wealth that the richest customer has.A customer’s wealth is the amount
2021-01-16 14:58:13 157
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人