LeetCode
文章平均质量分 56
Fannie08
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
[leetcode] 461. Hamming Distance
汉明距离:值两个整型数转换成二进制后对应位置不相同数(即一个数是0,同位置另一个数是1)的个数 或说成 一个数变成另一个数需要改变的数个数。如Input: x = 1, y = 4Output: 2Explanation:1 (0 0 0 1)4 (0 1 0 0) ↑ ↑【思路】1、求两个数二进制不同位,用异或运算符^。(^作用“相同出0原创 2018-01-12 10:07:52 · 311 阅读 · 0 评论 -
【LeetCode】476.Number Complement 补数
题目题目地址https://leetcode.com/problems/number-complement/description/Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representa原创 2018-01-17 16:57:47 · 708 阅读 · 0 评论 -
【LeetCode】557.Reverse Words in a String III
题目:https://leetcode.com/problems/reverse-words-in-a-string-iii/description/我的代码+学习代码原创 2018-01-19 10:36:47 · 280 阅读 · 0 评论 -
【LeetCode】500.Keyboard Row
题目:https://leetcode.com/problems/keyboard-row/description/Example 1:Input: ["Hello", "Alaska", "Dad", "Peace"]Output: ["Alaska", "Dad"]Note:You may use one character in the keybo原创 2018-01-20 11:09:50 · 344 阅读 · 0 评论 -
[LeetCode] 121.Best Time to Buy and Sell Stock
题意:给定一个数组arr,arr[i]表示第i天的股票价格,只能进行一次交易的情况下,且买入须在卖出股票之前,求最佳时间买入和卖出股票的最大收益。使用Kadane's Algorithm 算法,该算法是针对最大子序列问题 leetcode53。使用一个变量maxCur存目前的最大值,maxSoFar存最终的最大值。maxCur += prices[i] - prices[i-1] 计算...原创 2018-09-27 23:17:55 · 220 阅读 · 0 评论 -
leetcode 257 Binary Tree Paths
Given a binary tree, return all root-to-leaf paths.Note: A leaf is a node with no children.Example:Input: 1 / \2 3 \ 5Output: ["1->2->5", "1->3"]Explanation: All roo...原创 2018-10-23 10:45:24 · 256 阅读 · 0 评论 -
LeetCode【347】 Top K Frequent Elements
Given a non-empty array of integers, return the k most frequent elements.Example 1:Input: nums = [1,1,1,2,2,3], k = 2Output: [1,2]Example 2:Input: nums = [1], k = 1Output: [1]思路:1、首先遍...原创 2018-10-21 14:51:10 · 322 阅读 · 0 评论 -
LeetCode 23. Merge k Sorted Lists
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.Example:Input:[ 1->4->5, 1->3->4, 2->6]Output: 1->1->2->3->4-...原创 2018-10-21 15:48:19 · 246 阅读 · 0 评论
分享