- 博客(32)
- 资源 (6)
- 收藏
- 关注
原创 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 exists in
2016-10-27 23:55:40 199
原创 LeetCode 3. Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring without repeating characters.Examples:Given "abcabcbb", the answer is "abc", which the length is 3.Given "bbbbb", the answer is "
2016-10-26 17:49:49 168
原创 LeetCode 438. Find All Anagrams in a String
Given a string s and a non-empty string p, find all the start indices of p's anagrams in s.Strings consists of lowercase English letters only and the length of both strings s and p will not be lar
2016-10-26 12:29:15 251
原创 LeetCode 437. Path Sum III
You are given a binary tree in which each node contains an integer value.Find the number of paths that sum to a given value.The path does not need to start or end at the root or a leaf, but it
2016-10-25 13:11:10 827
原创 LeetCode 7. Reverse Integer
Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321把数据从低位到高位依次反转即可,注意有可能溢出,所以用long类型保存结果,然后判断是否溢出,溢出则返回0.class Solution {public: int reverse(in
2016-10-22 22:14:53 172
原创 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-10-22 21:57:52 234
原创 二分查找时mid的计算方法
如果用mid=(low+high)/2,在运行时可能超时。原因是int类型最大表示范围是2147483647,详细分析见我之前的一篇文章点击打开链接如果输入的low和high都接近2147483647,两个数相加就会溢出,变成一个负数。例:#includeint main(){ int low = 2147483647; int high = 2147483646; pri
2016-10-21 21:34:00 4038 4
原创 278. First Bad Version
You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the
2016-10-21 21:19:16 215
原创 414. Third Maximum Number
Given a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time complexity must be in O(n).Example 1:Input: [3, 2,
2016-10-21 20:52:59 375
原创 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
2016-10-21 20:23:42 225
原创 int类型整数的表示范围
32位int类型整数的范围,其中int类型是带符号整数。整数在计算机中表示为元码,最高位为符号位:1的元码为0000 0000 0000 00012147483647的元码为01111 1111 1111 1111所以最大的正整数是2147483647负数在计算机中表示为补码,最高位为符号位:-1的元码为1000 0000 0000 0001,反码为1111 1111
2016-10-18 23:47:24 95574 10
原创 LeetCode 155. Min Stack
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top() -- Get
2016-10-18 23:04:54 191
原创 LeetCode 6. ZigZag Conversion
The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H NA P L S I
2016-10-18 00:16:17 199
原创 LeetCode 405. 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 hexade
2016-10-16 18:10:59 220
原创 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”.
2016-10-15 20:03:45 773
原创 LeetCode 401. Binary Watch
A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom represent the minutes (0-59).Each LED represents a zero or one, with the least significant bit o
2016-10-14 20:14:07 289
原创 LeetCode 415. Add Strings
Given two non-negative numbers num1 and num2 represented as string, return the sum of num1 and num2.Note:The length of both num1 and num2 is Both num1 and num2 contains only digits 0-9.B
2016-10-13 18:46:07 226
原创 LeetCode 387. First Unique Character in a String
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:
2016-10-13 18:25:45 168
原创 LeetCode 409. Longest Palindrome
Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters.This is case sensitive, for example "Aa" is not con
2016-10-12 18:41:23 179
原创 LeetCode 404. Sum of Left Leaves
Find the sum of all left leaves in a given binary tree.Example: 3 / \ 9 20 / \ 15 7There are two left leaves in the binary tree, with values 9 and 15 respectively. Return 24
2016-10-11 20:51:11 208
原创 LeetCode 204. Count Primes
Description:Count the number of prime numbers less than a non-negative number, n.Credits:Special thanks to @mithmatt for adding this problem and creating all test cases.Hint:Let's
2016-10-11 19:56:33 170
原创 LeetCode 303. Range Sum Query - Immutable
Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.Example:Given nums = [-2, 0, 3, -5, 2, -1]sumRange(0, 2) -> 1sumRange(2, 5) -> -1sumRan
2016-10-09 08:54:32 182
原创 LeetCode 28. Implement strStr()
Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.暴力求解可以过。如果想用更好的算法,就去看KMP吧。class Solution {public: int strSt
2016-10-08 11:57:56 166
原创 LeetCode 1. 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.Example:Given nums =
2016-10-07 00:03:11 178
原创 C++ STL总结
1.stack#include声明:stack s;入栈:s.push(elem);出栈:s.pop();取栈顶元素:s.top();栈大小:s.size();判断是否为空:s.empty();2.queue#include声明:queue q;入队:q.push(elem);出队:s.pop();
2016-10-06 23:38:37 263
原创 LeetCode 397. Integer Replacement
Given a positive integer n and you can do operations as follow:If n is even, replace n with n/2.If n is odd, you can replace n with either n + 1 or n - 1.What is the minimum number o
2016-10-06 12:29:09 237
原创 LeetCode 396. Rotate Function
Given an array of integers A and let n to be its length.Assume Bk to be an array obtained by rotating the array A k positions clock-wise, we define a "rotation function" F on A as follow:
2016-10-05 00:09:40 160
原创 LeetCode 67. Add Binary
Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".让a和b的每个对应的数依次相加,用一个变量记录进位,相加时考虑进位,并不断修改进位即可。class Solution {public: strin
2016-10-03 23:41:13 286
原创 DFSZKFailoverController启动失败
配置hadoop的时候,DFSZKFailoverController启动失败。错误显示:ssh: Could not resolve hostname You: Temporary failure in name resolution最后终于找到了解决方法,是要配置一下环境变量。vim /etc/profile加入export HADOOP_COMMON_LIB_NATIVE
2016-10-03 09:36:11 12400
原创 数学运算符
位运算&按位与 1&1=1, 1&0=0, 0&1=0, 0&0=0 |按位或 1|1 = 1, 1|0 = 1, 0|1 = 1, 0|0 = 0 ^按位异或 1^1=0, 1^0=1, 0^1=1, 0^0=0~按位非 ~1 = 0, ~0 = 1 移位运算 >>右移 1111>>1=0111技巧:1.交换ab a=a∧b;
2016-10-03 00:10:53 678
原创 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
2016-10-02 23:56:45 192
原创 LeetCode 14. Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings.简单题,但是无奈用C语言提交了N次都不过,定义了一个char s[100]数组,让s[0] = a,返回s,但是执行结果总是null!!!!郁闷,只好用C++,顺利ac。class Solution {pu
2016-10-02 00:38:21 252
Hadoop技术内幕:深入解析HADOOP COMMON和HDFS架构设计与实现原理 目录完整版
2016-10-12
Hadoop技术内幕:深入解析HADOOP COMMON和HDFS架构设计与实现原理
2016-10-12
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人