- 博客(47)
- 资源 (15)
- 收藏
- 关注
原创 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 269
原创 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 231
原创 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 259
原创 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 217
原创 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 179
原创 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 164
原创 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 180
原创 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 164
原创 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 249
原创 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 217
原创 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 346
原创 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 171
原创 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 162
原创 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 192
原创 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 176
原创 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 161
原创 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 159
原创 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 168
原创 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 238
原创 九度OJ 1151 位操作练习
时间限制:1 秒内存限制:32 兆特殊判题:否提交:1986解决:1109题目描述:给出两个不大于65535的非负整数,判断其中一个的16位二进制表示形式,是否能由另一个的16位二进制表示形式经过循环左移若干位而得到。循环左移和普通左移的区别在于:最左边的那一位经过循环左移一位后就会被移到最右边去。比如:1011 0000 000
2017-04-01 22:50:11 267
原创 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 201
原创 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 223
原创 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 192
原创 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 153
原创 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 354 3
原创 PAT-甲级 1101 Quick Sort
1101. Quick Sort (25)时间限制200 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CAO, PengThere is a classical process named partition in
2017-03-31 19:22:44 570 2
原创 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 167
原创 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 153
原创 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 163
原创 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 220
原创 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 153
原创 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 183
原创 PAT-乙级 1007 素数对猜想
1007. 素数对猜想 (20)时间限制400 ms内存限制65536 kB代码长度限制8000 B判题程序Standard作者CHEN, Yue让我们定义 dn 为:dn = pn+1 - pn,其中 pi 是第i个素数。显然有 d1=1 且对于n>
2017-03-30 20:36:22 163
原创 PAT-甲级 1128 N Queens Puzzle
1128. N Queens Puzzle (20)时间限制300 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueThe "eight queens puzzle" is the problem o
2017-03-30 14:14:53 346
原创 PAT-乙级 1057 数零壹
1057. 数零壹(20)时间限制200 ms内存限制65536 kB代码长度限制8000 B判题程序Standard作者CHEN, Yue给定一串长度不超过105的字符串,本题要求你将其中所有英文字母的序号(字母a-z对应序号1-26,不分大小写)相
2017-03-30 14:07:02 205
原创 PAT-乙级 1056 组合数的和
1056. 组合数的和(15)时间限制400 ms内存限制65536 kB代码长度限制8000 B判题程序Standard作者CHEN, Yue给定N个非0的个位数字,用其中任意2个数字都可以组合成1个2位的数字。要求所有可能组合出来的2位数字的和。例
2017-03-30 14:02:07 287
原创 PAT-乙级 1069 微博转发抽奖
1069. 微博转发抽奖(20)时间限制400 ms内存限制65536 kB代码长度限制8000 B判题程序Standard作者CHEN, Yue小明PAT考了满分,高兴之余决定发起微博转发抽奖活动,从转发的网友中按顺序每隔N个人就发出一个红包。请你编
2017-03-30 13:47:25 266
原创 PAT-乙级 1070 结绳
1070. 结绳(25)时间限制200 ms内存限制65536 kB代码长度限制8000 B判题程序Standard作者CHEN, Yue给定一段一段的绳子,你需要把它们串成一条绳。每次串连的时候,是把两段绳子对折,再如下图所示套接在一起。这样得到的绳
2017-03-29 20:02:50 899
原创 PAT-乙级 1021 个位数统计
1021. 个位数统计 (15)时间限制100 ms内存限制65536 kB代码长度限制8000 B判题程序Standard作者CHEN, Yue给定一个k位整数N = dk-1*10k-1 + ... + d1*101 + d0 (0i<=9, i=
2017-03-29 19:58:20 203
QT VS2010 坦克大战
2013-08-28
城市之间最短路径管理软件
2013-08-22
基于windows窗体程序的稀疏矩阵显示及相加
2013-05-08
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人