![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode
hemmingway
该家伙很懒。
展开
-
Maximum Depth of Binary Tree
https://leetcode.com/problems/maximum-depth-of-binary-tree/Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the far原创 2016-07-22 23:21:30 · 395 阅读 · 0 评论 -
Power of Three
https://leetcode.com/problems/power-of-three/Given an integer, write a function to determine if it is a power of three.Follow up: Could you do it without using any loop / recursion?3的次方数没有显著的特点,最直接的方法原创 2016-07-24 10:25:35 · 264 阅读 · 0 评论 -
Ugly Number
https://leetcode.com/problems/ugly-number/Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 6, 8原创 2016-07-24 10:44:42 · 285 阅读 · 0 评论 -
Reverse Bits
Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary as 00111001011110原创 2016-07-24 22:31:40 · 426 阅读 · 0 评论 -
Single Number
https://leetcode.com/problems/single-number/Given an array of integers, every element appears twice except for one. Find that single one.Note: Your algorithm should have a linear runtime complexity. C原创 2016-07-27 00:28:02 · 297 阅读 · 0 评论 -
Missing Number
https://leetcode.com/problems/missing-number/Given an array containing n distinct numbers taken from 0, 1, 2, …, n, find the one that is missing from the array.For example, Given nums = [0, 1, 3] retu原创 2016-07-27 00:42:33 · 331 阅读 · 0 评论 -
String to Integer (atoi)
https://leetcode.com/problems/string-to-integer-atoi/Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below原创 2016-07-28 22:37:11 · 504 阅读 · 0 评论 -
Reverse Integer
https://leetcode.com/problems/reverse-integer/Reverse digits of an integer.Example1: x = 123, return 321 Example2: x = -123, return -321Have you thought about this? Here are some good questions to as原创 2016-07-28 22:51:45 · 347 阅读 · 0 评论 -
reverse string
https://leetcode.com/problems/reverse-string/Write a function that takes a string as input and returns the string reversed.Example: Given s = “hello”, return “olleh”.1.char* reverseString(char* s) {原创 2016-07-21 23:09:37 · 275 阅读 · 0 评论 -
Add Digits
https://leetcode.com/problems/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,原创 2016-07-22 00:35:07 · 297 阅读 · 0 评论 -
Power of Four
https://leetcode.com/problems/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 num = 5, return false.Fo原创 2016-07-24 10:17:10 · 309 阅读 · 0 评论 -
sum of two integers
https://leetcode.com/problems/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.注释,这个题目有意思,学过F原创 2016-07-21 23:46:05 · 322 阅读 · 0 评论 -
Invert Binary Tree
https://leetcode.com/problems/invert-binary-tree/Invert a binary tree.4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1给出一棵二叉树,求这棵二叉树的镜像。搬运九章上的实现原创 2016-07-22 23:46:38 · 294 阅读 · 0 评论 -
Move Zeroes
https://leetcode.com/problems/move-zeroes/Given an array nums, write a function to move all 0’s to the end of it while maintaining the relative order of the non-zero elements.For example, given nums =原创 2016-07-23 00:24:56 · 280 阅读 · 0 评论 -
Intersection of Two Arrays
https://leetcode.com/problems/intersection-of-two-arrays/Given two arrays, write a function to compute their intersection.Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2].Note: Each el原创 2016-07-23 11:44:46 · 326 阅读 · 0 评论 -
Contains Duplicate
https://leetcode.com/problems/contains-duplicate/Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array原创 2016-07-23 12:24:23 · 340 阅读 · 0 评论 -
Contains Duplicate II
https://leetcode.com/problems/contains-duplicate-ii/Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the原创 2016-07-23 14:05:53 · 347 阅读 · 0 评论 -
Power of Two
https://leetcode.com/problems/power-of-two/Given an integer, write a function to determine if it is a power of two.数字 2^n 是大于0的,而且等于1左移n位得到的数字,所以2^n与2^n-1 相与运算得到0.bool isPowerOfTwo(int n) { if(n <=原创 2016-07-23 14:37:52 · 271 阅读 · 0 评论 -
Number of 1 Bits
https://leetcode.com/problems/number-of-1-bits/Write a function that takes an unsigned integer and returns the number of ’1’ bits it has (also known as the Hamming weight).For example, the 32-bit integ原创 2016-07-23 14:57:53 · 245 阅读 · 0 评论 -
Counting Bits
https://leetcode.com/problems/counting-bits/Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1’s in their binary representation and return t原创 2016-07-23 16:26:42 · 273 阅读 · 0 评论 -
Add Binary
https://leetcode.com/problems/add-binary/Given two binary strings, return their sum (also a binary string).For example, a = “11” b = “1” Return “100”.计算过程类似Verilog的全加器。char* addBinary(char* a, char*原创 2016-07-23 17:48:48 · 304 阅读 · 0 评论 -
387. First Unique Character in a String QuestionEditorial Solution
Given a string, find the first non-repeating character in it and return it’s index. If it doesn’t exist, return -1.Examples:s = “leetcode” return 0.s = “loveleetcode”, return 2. Note: You may assume原创 2016-08-29 23:48:10 · 589 阅读 · 0 评论