自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(27)
  • 收藏
  • 关注

原创 LeetCode 206. Reverse Linked List

问题描述:Reverse a singly linked list.单链表反转。AC代码:ListNode* reverseList(ListNode* head) { ListNode *reverseHead = NULL; ListNode *pre = NULL; ListNode *cur = head;

2016-06-24 16:55:27 234

原创 LeetCode 350. Intersection of Two Arrays II

问题描述:Given two arrays, write a function to compute their intersection.Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2].Note:Each element in the result should a

2016-06-24 16:32:59 227

原创 LeetCode 220. Contains Duplicate III

问题描述:Given an array of integers, find out whether there are two distinct indices i and j in the array such that the difference between nums[i] and nums[j] is at most t and the difference betwe

2016-06-24 11:21:59 799

原创 LeetCode 217. 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, and it should return false if every e

2016-06-23 11:35:03 213

原创 LeetCode 242. Valid Anagram

问题描述:Given two strings s and t, write a function to determine if t is an anagram of s.For example,s = "anagram", t = "nagaram", return true.s = "rat", t = "car", return false.Note:

2016-06-22 15:37:57 208

原创 LeetCode 168. Excel Sheet Column Title

问题描述:Given a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA 28 -> AB

2016-06-22 15:23:41 248

原创 LeetCode 171. Excel Sheet Column Number

问题描述:Related to question Excel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For example: A -> 1 B -> 2 C -> 3

2016-06-22 15:06:02 217

原创 LeetCode 100. Same Tree

问题描述:Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value.简

2016-06-22 10:49:12 190

原创 LeetCode 203. Remove Linked List Elements

问题描述:Remove all elements from a linked list of integers that have value val.ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 --> 2 --> 3 --> 4 --> 5AC代码: ListNo

2016-06-22 10:29:12 191

原创 LeetCode 237. Delete Node in a Linked List

问题描述:Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third node

2016-06-22 09:58:11 187

原创 LeetCode 283. 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 = [0, 1, 0, 3, 12], after

2016-06-21 20:31:37 202

原创 LeetCode 226. Invert Binary Tree

问题描述:Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1Trivia:This problem was inspired by this original tweet by

2016-06-21 11:20:37 253

原创 LeetCode 111. Minimum Depth of Binary Tree

问题描述: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. int minDepth(TreeNode* r

2016-06-17 16:31:25 180

原创 LeetCode 104. 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 farthest leaf node.AC代码: int maxDepth(Tree

2016-06-17 15:37:48 214

原创 LeetCode 70. Climbing Stairs

问题描述:You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?题目其实就是求斐波拉契数列f(n)

2016-06-17 15:08:25 206

原创 LeetCode 299. Bulls and Cows

问题描述:You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time your friend makes a guess, you provi

2016-06-17 11:31:22 204

原创 LeetCode 349. 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].AC代码:vector intersection(vector& nums1, vector& n

2016-06-16 11:29:05 219

原创 LeetCode 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 num = 5, return false.Follow up: Could you solve

2016-06-16 10:37:45 202

原创 LeetCode 231. Power of Two

问题描述:Given an integer, write a function to determine if it is a power of two.判断一个数是否为2的次方举例看2的次方数及其二进制表示如下,1(0)、2(10)、4(100)、8(1000)、16(10000)······满足2的次幂的数的二进制表示只有一个1,且一定是最高位为1.到这里思路就清晰

2016-06-16 09:58:24 236

原创 LeetCode 191. 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 integer ’11' has binary representa

2016-06-16 09:53:29 172

原创 Leetcode 190. 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 a

2016-06-16 09:52:05 202

原创 LeetCode 38. Count and Say

问题描述:The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1 is read off as "one 1" or 11.11 is read off as "two 1s" or 21.21 is read

2016-06-03 11:56:27 238

原创 LeetCode 33. Search in Rotated Sorted Array

问题描述:Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target value to search. If found in the

2016-06-02 15:47:26 311

原创 LeetCode 153. Find Minimum in Rotated Sorted Array

问题描述:Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).Find the minimum element.You may assume no duplicate

2016-06-02 15:41:48 185

原创 LeetCode 67. Add Binary

问题描述:Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".题目大意:用字符串实现二进制数的加法。1.字符串长度不一定同,因此反转字符串在做加法,最后得到的结果在反转。2.注意最高位的进

2016-06-01 20:32:14 211

原创 Leetcode 43. Multiply Strings

题目描述:Given two numbers represented as strings, return multiplication of the numbers as a string.Note:The numbers can be arbitrarily large and are non-negative.Converting the input stri

2016-06-01 19:32:46 256

原创 LeetCode 66. Plus One

问题描述:Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant digit is at the head of the list.问题大意:用一个数组表

2016-06-01 15:39:37 197

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除