![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
----LeetCode
文章平均质量分 50
南哪儿
这个作者很懒,什么都没留下…
展开
-
LeetCode 083 Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, return 1->2->3.AC代码如下:/** * Definit原创 2017-04-06 23:19:23 · 225 阅读 · 0 评论 -
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 ...原创 2017-04-01 17:14:30 · 214 阅读 · 0 评论 -
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 as 001110010原创 2017-04-11 12:53:21 · 331 阅读 · 0 评论 -
LeetCode 153 Find Minimum in Rotated Sorted Array
Suppose an array sorted in ascending order 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原创 2017-04-11 13:52:46 · 206 阅读 · 0 评论 -
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 representation 000000原创 2017-04-01 18:17:54 · 193 阅读 · 0 评论 -
LeetCode 066 Plus One
Given a non-negative integer represented as a non-empty array of digits, plus one to the integer.You may assume the integer do not contain any leading zero, except the number 0 itself.The digi原创 2017-04-12 23:38:18 · 234 阅读 · 0 评论 -
LeetCode 461 Hamming Distance
The Hamming distance between two integers is the number of positions at which the corresponding bits are different.Given two integers x and y, calculate the Hamming distance.Note:0 ≤ x,原创 2017-04-13 21:01:38 · 151 阅读 · 0 评论 -
LeetCode 118 Pascal's Triangle
Given numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]AC代码如下:class Solution {pu原创 2017-04-14 16:47:55 · 170 阅读 · 0 评论 -
LeetCode 125 Valid Palindrome
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Panama" is a palindrome."race a car" is not a原创 2017-04-14 22:43:04 · 154 阅读 · 0 评论 -
LeetCode 260 Single Number III
Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once.For example:Given原创 2017-04-14 23:05:16 · 169 阅读 · 0 评论 -
LeetCode 412 Fizz Buzz
Write a program that outputs the string representation of numbers from 1 to n.But for multiples of three it should output “Fizz” instead of the number and for the multiples of five output “Buzz”.原创 2017-04-16 09:04:02 · 206 阅读 · 0 评论 -
LeetCode 026 Remove Duplicates from Sorted Array
Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this in place with原创 2017-04-16 19:09:59 · 250 阅读 · 0 评论 -
LeetCode 070 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?Note: Given n will be a posi原创 2017-04-16 20:18:41 · 218 阅读 · 0 评论 -
LeetCode 004 Median of Two Sorted Arrays
There are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).Example 1:nums1 =原创 2017-04-17 08:02:35 · 260 阅读 · 0 评论 -
LeetCode 034 Search for a Range
Given an array of integers sorted in ascending order, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the order of O(log n).If the原创 2017-04-01 12:10:30 · 180 阅读 · 0 评论 -
LeetCode 035 Search Insert Position
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the array.原创 2017-04-01 11:57:51 · 141 阅读 · 0 评论 -
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.AC代码如下:原创 2017-03-31 20:08:03 · 349 阅读 · 3 评论 -
LeetCode 021 Merge Two Sorted Lists
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.AC代码如下:/** * Definition for singly-linked list. * s原创 2017-04-07 09:59:08 · 158 阅读 · 0 评论 -
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 calling you原创 2017-04-07 15:04:03 · 146 阅读 · 0 评论 -
LeetCode 268 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] return 2.Note:Your algorithm sho原创 2017-04-07 15:13:32 · 150 阅读 · 0 评论 -
LeetCode 344 Reverse String
Write a function that takes a string as input and returns the string reversed.Example:Given s = "hello", return "olleh".AC代码如下:class Solution {public: string reverseString(string s) {原创 2017-04-07 15:43:44 · 165 阅读 · 0 评论 -
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代码如下:/** * Definiti原创 2017-04-07 20:33:04 · 182 阅读 · 0 评论 -
LeetCode 027 Remove Element
Given an array and a value, remove all instances of that value in place and return the new length.Do not allocate extra space for another array, you must do this in place with constant memory.原创 2017-04-07 20:46:32 · 152 阅读 · 0 评论 -
LeetCode 557 Reverse Words in a String III
Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.Example 1:Input: "Let's take LeetCode contes原创 2017-04-09 23:24:00 · 158 阅读 · 0 评论 -
LeetCode 001 Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use the sam原创 2017-03-30 23:20:29 · 174 阅读 · 0 评论 -
LeetCode 136 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. Could you implement it without using e原创 2017-03-31 12:39:41 · 142 阅读 · 0 评论 -
LeetCode 141 Linked List Cycle
Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?AC代码如下:/** * Definition for singly-linked list. * struct ListNode { * int原创 2017-03-31 13:26:12 · 210 阅读 · 0 评论 -
LeetCode 058 Length of Last Word
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, return 0.Note: A word is原创 2017-03-31 13:45:08 · 153 阅读 · 0 评论 -
LeetCode 204 Count Primes
Description:Count the number of prime numbers less than a non-negative number, n.AC代码如下:class Solution {public: int countPrimes(int n) { int ret=0; if(n<=2)原创 2017-03-31 17:03:40 · 145 阅读 · 0 评论 -
LeetCode 231 Power of Two
Given an integer, write a function to determine if it is a power of two.AC代码如下:class Solution {public: bool isPowerOfTwo(int n) { if(n<=0) return false; int count=原创 2017-03-31 18:26:46 · 156 阅读 · 0 评论 -
学习总结 求某年某月某日之后第N天日期的解法
一个求解某年某月某日之后第N天日期算法的代码,值得一看。原创 2017-04-20 22:42:07 · 573 阅读 · 0 评论