![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode
pw007992
这个作者很懒,什么都没留下…
展开
-
leetcode 342. Power of Four
关于 leetcode中342. Power of Four我的做法: 首先问题是这样的: 342. Power of Four Given an integer (signed 32 bits), write a function to check whether it is a power of 4.Example: Given num = 16, return true. Given原创 2016-05-15 16:31:52 · 293 阅读 · 0 评论 -
Convert a Number to Hexadecimal
Given an integer, write an algorithm to convert it to hexadecimal. For negative integer, two’s complement method is used.Note:All letters in hexadecimal (a-f) must be in lowercase. The hexadecimal str原创 2016-11-21 19:18:55 · 284 阅读 · 0 评论 -
Number of Boomerangs及pair数据的使用
Given n points in the plane that are all pairwise distinct, a “boomerang” is a tuple of points (i, j, k) such that the distance between i and j equals the distance between i and k (the order of the tup原创 2016-11-20 14:59:07 · 330 阅读 · 0 评论 -
博客转移
现在博客开始逐渐往简书上转移了。。。原创 2016-12-11 10:51:17 · 389 阅读 · 0 评论 -
Add Digits
题目: Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one dig原创 2016-11-02 21:01:37 · 213 阅读 · 0 评论 -
leetcode_Minimum Moves to Equal Array Elements
Given a non-empty integer array of size n, find the minimum number of moves required to make all array elements equal, where a move is incrementing n - 1 elements by 1. eg:Input: [1,2,3]Output: 3Expla原创 2016-11-12 12:40:23 · 298 阅读 · 0 评论 -
Maximum Depth of Binary Tree
在接触二叉树以前,先回顾一下二叉树的几个性质: 1.节点个数为A, 总度数为B,因为除了根节点,每个节点都有一个入度,所以 A=B+ 1 2.总度数=2 * n_2 + n_1(n_2和n_1分别是度为2和度为1的节点数),又因为 A = n_2 + n_1 + n_0,所以有n_2 + n_1 + n_0 = 2 * n_2 + n_1 + 1 所以n2 + 1 = n_0 3.树的原创 2016-10-31 10:02:53 · 345 阅读 · 0 评论 -
栈的压入、弹出序列题解
题目: 输入两个整数序列,第一个序列表示栈的压入顺序,请判断第二个序列是否为该栈的弹出顺序。假设压入栈的所有数字均不相等。例如序列1,2,3,4,5是某栈的压入顺序,序列4,5,3,2,1是该压栈序列对应的一个弹出序列,但4,3,5,1,2就不可能是该压栈序列的弹出序列。(注意:这两个序列的长度是相等的)思路:开辟一个辅助栈,模拟入栈序列的入栈和出栈序列的出栈,当栈顶元素和出栈栈顶元素相同时,栈顶原创 2016-10-27 10:37:53 · 335 阅读 · 0 评论 -
Sum of Two Integers 解题报告
题目: Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -.Example: Given a = 1 and b = 2, return 3.即给你两个数,让你求它们的和,但不能使用+和-刚开始看到这个题的时候,感觉没有思路,后来借鉴了别人博客里的思想,可以用原创 2016-10-26 16:11:02 · 240 阅读 · 0 评论 -
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 day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock), desi原创 2016-11-24 10:45:08 · 538 阅读 · 0 评论