- 博客(7)
- 收藏
- 关注
原创 判断输入的字符串在键盘中是否为同一行 Keyboard Row
题目描述、样例及注意事项: Given a List of words, return the words that can be typed using letters of alphabet on only one row’s of American keyboard like the image below. Example 1: Input: [“Hello”, “Alaska”, “
2017-12-28 22:34:52 419
原创 LeetCode 买卖股票的合适时间
最近在看贪心算法及相关内容,找出了leetcode相关的专题来做,碰到了买卖股票的一系列问题,故记录以备之。一、入门一级:只能买卖一次股票,求最大利润Title: Best Time to Buy and Sell Stock Say you have an array for which the ith element is the price of a given stock on da
2017-12-20 09:52:00 4982 1
原创 求二进制中1的个数
题目描述: 输入一个整数,输出该数二进制表示中1的个数。其中负数用补码表示。复习了一下原码、反码、补码的转换关系及来源,看到一个博客介绍的很详细,包括原码与补码本质上取模运算后得到的结果是相同的。 https://www.cnblogs.com/zhangziqiu/archive/2011/03/30/ComputerCode.html本题的方法很巧妙,通过每次n-1再与n作与操作,其实是将最
2017-12-07 22:30:17 208
原创 树 求树的最小深度、最大深度
一、二叉树的最小深度Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.求解此类问题要先明确递归状态及递归条件,考虑清楚是否有漏洞。本题有
2017-12-06 16:24:39 3654
原创 LeetCode Find K-th Smallest Pair Distance
Given an integer array, return the k-th smallest distance among all the pairs. The distance of a pair (A, B) is defined as the absolute difference between A and B.Example 1: Input: nums = [1,3,1] k
2017-12-04 16:52:06 332
原创 LeetCode 646. Maximum Length of Pair Chain
问题描述: You are given n pairs of numbers. In every pair, the first number is always smaller than the second number.Now, we define a pair (c, d) can follow another pair (a, b) if and only if b < c. Chain
2017-12-02 17:58:34 122
原创 LeetCode 135. Candy
题目要求: There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child must have at least one
2017-12-01 20:21:34 163
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人