- 博客(18)
- 资源 (4)
- 收藏
- 关注
原创 9. Palindrome Number
Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Some hints: Could negative integers be palindromes? (ie, -1)If you are thinking of converting the integ
2016-01-19 23:26:29 268
原创 java 两数相减
比如 -3-4=-7-3用二进制表示为: 3的二进制取反,得到反码,反码+1得到补码。 即 0000 0011–>取反–>1111 1100–>+1–>1111 1101 -4表示为 0000 0100->1111 1011->1111 1100. 即 1111 1101 +111 11001111 1001 在根据补码得出结果,即 补码-1=反码 反码取反得到原码,即 1111
2016-01-13 21:10:41 2739
原创 7. Reverse Integer
Reverse digits of an integer.Example1: x = 123, return 321 Example2: x = -123, return -321click to show spoilers.Have you thought about this? Here are some good questions to ask before coding. Bonus
2016-01-13 20:59:07 240
原创 Java中整数溢出的问题:int i=1000000;i*i为何等于-727379968,Java是如何处理溢出的?
原提问地址:http://bbs.csdn.net/topics/40216116 问题: 读Java语言说明书到34页的时候碰到了一个整数相乘溢出的问题,百思不得其解,诚请行家指点。int i=1000000;i*i为何等于-727379968?书中说乘法是安装32位精度计算的。-727379968是计算结果1000000000000的低32位的十进制表示,计算结果对int类型来说太大了。怕英
2016-01-13 20:04:04 2231
原创 爬虫技术分享
(一)网络爬虫 网络爬虫是一个自动提取网页的程序或者脚本,其原理就是用程序模拟浏览器的访问行为,进行网页的下载。(二)网络爬虫的基本结构及工作流程一个通用的网络爬虫的框架如图所示:网络爬虫的基本工作流程如下:1.首先选取一部分精心挑选的种子URL;2.将这些URL放入待抓取URL队列;3.从待抓取URL队列中取出待抓取在URL,解析DNS,并且得到主机的ip,并将URL对应的网页下载下来
2016-01-08 16:22:24 460
原创 263. 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 are ugly while 14 is not ugly since it in
2016-01-06 21:31:01 201
原创 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-01-06 00:18:53 231
原创 290. Word Pattern
Given a pattern and a string str, find if str follows the same pattern.Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in str.Examples:
2016-01-05 21:06:38 232
原创 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 your funct
2016-01-04 23:47:49 214
原创 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) -> 1 sumRange(2, 5) -> -1 sumRange(0, 5
2016-01-04 22:04:05 252
原创 Cpdetector
cpdector 就是一款文档编码检测工具,可以检测 xml,html文档编码类型。是爬虫,浏览器的一款很好的辅助工具。 是基于统计学原理的,来判断文档的编码,不保证正确。文档开始都是字节流,要根据字节流得到编码类型。那么 ascii 编码占用一个字节,iso8859-1也是占用1个字节,utf-8是可变长编码占用字节不确定,gbk编码占用2个字节。那么它怎么根据字节流来推断其编码呢?因为肯定
2016-01-03 20:37:24 2477
原创 182. Duplicate Emails My Submissions Question
Duplicate Emails My Submissions Question Total Accepted: 12918 Total Submissions: 34402 Difficulty: Easy Write a SQL query to find all duplicate emails in a table named Person.+—-+———+ | Id | Email
2016-01-02 19:38:40 288
原创 爬虫乱码的解决办法
写爬虫时肯定是要去考虑乱码的问题,刚开始自己没怎么有思路,最后看了亮哥解决乱码的博客。才明白,主要一下几点:1:解析服务端返回的header中content-type. 得到编码,改编码是什么就按照什么去解析返回的字节流。 2:如果服务端header中没有content-type信息,就按照 utf-8 解析返回的内容 。再去解析meta标签 得到编码,并作为最终的解析服务端返回字节流的编码。(因
2016-01-02 19:01:25 4243
原创 303,Range Sum Query
303,Range Sum QueryGiven 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) -> 1 sumRange(2, 5) ->
2016-01-02 18:30:24 242
原创 292. Nim Game My Submissions Question
292. Nim Game My Submissions QuestionTotal Accepted: 30656 Total Submissions: 60993 Difficulty: Easy You are playing the following Nim Game with your friend: There is a heap of stones on the table, ea
2015-12-30 15:43:56 1121
原创 258. Add Digits
258. Add DigitsproblemGiven 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, 1 + 1 = 2. Since 2
2015-12-29 00:26:39 211
原创 leetcode 13 罗马数字转10进制
leetcode 13 罗马数字转10进制今天是第一天开刷leetcode。知道了QJ神马玩意 ^^… .感觉自己算法简直弱爆了,小学生都可以吊打。事实就是这样,但有颗不服气的心,一直想去提高自己的算法水平,但又不知道何从下手,于是乎丛刷题开始,由点及面,总会有提高的^^。也不知道刷完了的感觉会是怎么样的,算法水平到底会提高到如何程度, 是葵花宝典 ,还是辟邪剑谱。这几个月会努力刷题。思路:
2015-12-28 00:01:43 340
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人