### 题意 Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. 给定一个大小为 n 的数组,找到其中的众数。众数是指在数组中出现次数大于 ⌊ n/2 ⌋ 的元素。 You may assume that the array is non-empty and the major...
阅读全文>>2018年3月31日 22:04 作者:nancy 分类:[LeetCode] 1332
### 题意 Say you have an array for which the ith element is the price of a given stock on day i. 给定一个数组,它的第 i 个元素是一支给定股票第 i 天的价格。 Design an algorithm to find the maximum profit. You may complete as many transactions as you like (i.e., buy one...
阅读全文>>2018年3月30日 21:09 作者:nancy 分类:[LeetCode] 1233
### 题意 Say you have an array for which the `i**th` element is the price of a given stock on day i. 给定一个数组,它的第 i 个元素是一支给定股票第 i 天的价格。 If you were only permitted to complete at most one transaction (i.e., buy one and sell one share of the stoc...
阅读全文>>2018年3月29日 22:14 作者:nancy 分类:[LeetCode] 1520
### 题意 Given a non-negative index k where k ≤ 33, return the `k**th` index row of the Pascal's triangle. 给定一个非负索引 k,其中 k ≤ 33,返回杨辉三角的第 k 行。 Note that the row index starts from 0. 请注意,行索引从0开始。 Example: ```python Input: 3 Output: [1,...
阅读全文>>2018年3月28日 19:31 作者:nancy 分类:[LeetCode] 1243
```python from urllib.parse import urlparse ``` Error:ImportError: No module named parse 错误原因: 出现这个错误,是因为我使用的是 Python2.7 [根据Python 2.x urlparse模块文档](https://docs.python.org/2/library/urlparse.html) Python 2.7 中使用: ```python from url...
阅读全文>>2018年3月28日 19:19 作者:nancy 分类:[Python] 1486
### 题意 Given a non-negative integer numRows, generate the first numRows of Pascal's triangle. 给定一个非负整数 numRows,生成杨辉三角的前 numRows 行。 Example: ```python Input: 5 Output: [ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] ] ...
阅读全文>>2018年3月27日 20:52 作者:nancy 分类:[LeetCode] 1222
### 题意 Given an array of integers, return indices of the two numbers such that they add up to a specific target. 给定一个整数数组和一个目标值,找出数组中和为目标值的两个数。 You may assume that each input would have exactly one solution, and you may not use the same ele...
阅读全文>>2018年3月26日 22:56 作者:nancy 分类:[LeetCode] 1248
### Ubuntu 用户安装或升级使用下面的命令(支持所有版本 Ubuntu 系统) ```python sudo apt-get update sudo apt-get install firefox ``` ### 查看版本 打开firefox,点菜单栏 Help->About Firefox ### Firefox 安装路径 1.打开一个火狐浏览器 2.打开一个终端,输入:ps -ef | grep firefox ### Python sele...
阅读全文>>2018年3月25日 21:10 作者:nancy 分类:[Python] 2296
### 题意 Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. 给定两个有序整数数组 nums1 和 nums2,将 nums2 合并到 nums1 中,使得 num1 成为一个有序数组。 Note: The number of elements initialized in nums1 and nums2 are m and n re...
阅读全文>>2018年3月25日 20:35 作者:nancy 分类:[LeetCode] 1309
### 题意 Given a non-empty array of digits representing a non-negative integer, plus one to the integer. 给定一个非负整数组成的非空数组,在该数的基础上加一,返回一个新的数组。 The digits are stored such that the most significant digit is at the head of the list, and each eleme...
阅读全文>>2018年3月24日 21:45 作者:nancy 分类:[LeetCode] 1211
你还没有登录,请 或者