- 博客(63)
- 资源 (1)
- 收藏
- 关注
原创 Python爬取Carmax数据
import requestsimport reimport xlwtPage=1zip=94701StartIndex=0#url1="https://www.carmax.com/search#Distance=all&Page=3&Zip=90470"book = xlwt.Workbook(encoding='utf-8',style_compression=0)she
2016-09-25 14:45:50 1256
原创 python模拟登录新浪微博自动获得调用新浪api所需的code
用这篇文章来记录一下从头到尾调用新浪api的过程一、安装api第一步肯定是要先安装新浪微博的库,安装了pip的同学直接在cmd中执行pip install weibo便可安装成功二、获得OAuth2.0的授权授权机制如下图所示该链接中有介绍:点击打开链接首先我们需要App key和App Secret,这两个创建一个sina应用便会发送给你接
2015-12-21 16:25:58 10402 5
原创 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 element is
2015-07-26 20:31:52 972
原创 Rectangle Area
Find the total area covered by two rectilinear rectangles in a2D plane.Each rectangle is defined by its bottom left corner and top right corner as shown in the figure.Assume that the total a
2015-07-26 17:15:17 502
原创 Power of Two
Given an integer, write a function to determine if it is a power of two.给一个整数,判断是否是2的幂。2的幂的2进制数只有最高位为1,减1之后全为1。所以2的幂n&(n-1)==0.代码如下:class Solution {public: bool isPowerOfTwo(int n) {
2015-07-21 22:57:07 337
原创 Palindrome Linked List
Given a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space?判断一个链表是否为回文序列。遍历一次存入vector,便利第二次判断是否回文;但是这样的空间复杂副就是O(n)。代码如下:/** * Definiti
2015-07-21 21:48:00 321
原创 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 with value
2015-07-17 18:24:45 404
转载 Win32串口编程(C++)
原地址:http://www.vckbase.com/index.php/Old/index/id/1734Win32串口编程作者:韩耀旭下载源代码 在工业控制中,工控机(一般都基于Windows平台)经常需要与智能仪表通过串口进行通信。串口通信方便易行,应用广泛。一般情况下,工控机和各智能仪表通过RS485总线进行通信。RS485的通信方式是半双工的,只
2015-04-22 18:56:20 609
转载 ARM指令后缀与常用读取指令
原地址:http://blog.csdn.net/cangencong/article/details/6890933一:指令可选后缀“S”后缀:指令中使用“S”后缀,指令执行后状态寄存器的条件标志位将被刷新;不使用“S”后缀时,指令执行后状态寄存器的条件标志位不会发生变化。此标志经常用于对条件进行测试,例如:是否溢出,是否进位等;根据这些变化,就可以进行一些判断,是否大于,是否相
2015-04-19 19:57:52 518
转载 JDK,JRE,JVM区别与联系
原地址:http://java-mzd.iteye.com/blog/838514 很多朋友可能跟我一样,已经使用JAVA开发很久了,可是对JDK,JRE,JVM这三者的联系与区别,一直都是模模糊糊的。 今天特写此文,来整理下三者的关系。 JDK : Java Development ToolKit(Java开发工具包)。JDK是整个JAVA的核心,包括了Jav
2015-03-19 18:09:02 378
原创 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 ext
2015-03-18 15:03:39 423
原创 Linked List Cycle II
Given a linked list, return the node where the cycle begins. If there is no cycle, return null.Follow up:Can you solve it without using extra space?给定一个链表,返回环形开始的节点,如果没有环形,返回null对于判断
2015-03-18 11:33:32 392
原创 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?给定一个链表,判断他是否是环形链表定义两个指针,一个一次走一步,一个一次走两步,如果有回路他们最终肯定会碰面,代码如下:/** * Definit
2015-03-18 11:30:57 356
原创 Reorder List
Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For example,Given {1,2,3,4}, reorder it to
2015-03-18 10:56:16 390
原创 Longest Consecutive Sequence
Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given [100, 4, 200, 1, 3, 2],The longest consecutive elements sequence is [1, 2, 3
2015-03-17 23:23:32 334
原创 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
2015-03-17 22:32:19 305
原创 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.给定一组数字代表一个非负数,让这个数加一
2015-03-17 22:26:23 366
原创 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.给定一个有序链表,删除所有重复的元素让每一个元
2015-03-17 22:23:57 324
原创 Path Sum
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example:Given the below binary tree and sum
2015-03-17 22:17:37 280
原创 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]]返回一个杨辉三角,知道杨辉三角规律就很简单了,代码如下:
2015-03-17 22:16:26 271
原创 Maximum Product Subarray
Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array [2,3,-2,4],the contiguous subarray [2,3] has the largest
2015-03-14 15:23:32 453
原创 Find Minimum in Rotated Sorted Array II
Follow up for "Find Minimum in Rotated Sorted Array":What if duplicates are allowed?Would this affect the run-time complexity? How and why?Suppose a sorted array is rotated at some pivot unk
2015-03-14 15:18:57 914
原创 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
2015-03-14 15:13:41 286
原创 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
2015-03-14 15:09:47 544
原创 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 as0011100101
2015-03-14 14:55:42 336
原创 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 00000000
2015-03-14 14:28:36 309
原创 Balanced Binary Tree
Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never diffe
2015-03-07 13:35:01 409
原创 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 convertin
2015-02-14 21:22:34 353
转载 求0x5f3759df的数学原理
Quake-III Arena (雷神之锤3)是90年代的经典游戏之一。该系列的游戏不但画面和内容不错,而且即使计算机配置低,也能极其流畅地运行。这要归功于它3D引擎的开发者约翰-卡马克(John Carmack)。事实上早在90年代初DOS时代,只要能在PC上搞个小动画都能让人惊叹一番的时候,John Carmack就推出了石破天惊的Castle Wolfstein, 然后再接再励,doom,
2015-02-08 12:10:20 1135
原创 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
2015-02-06 21:15:52 289
原创 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 off as
2015-02-06 19:56:06 289
原创 Pascal's Triangle II
Given an index k, return the kth row of the Pascal's triangle.For example, given k = 3,Return [1,3,3,1].Note:Could you optimize your algorithm to use only O(k) extra space?求杨辉三角第k行的数据。
2015-02-06 18:35:36 218
原创 Add Two Numbers
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a link
2015-02-06 15:11:49 279
原创 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
2015-02-05 18:43:49 531
原创 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 Credits
2015-02-05 18:04:02 281
原创 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 ...
2015-02-05 17:44:59 1075
原创 Factorial Trailing Zeroes
Given an integer n, return the number of trailing zeroes in n!.Note: Your solution should be in logarithmic time complexity.给一个整数n,返回n!后面0的个数。n!的个数就是其中质因数2和5个数的个数,所以只要求出5的个数就是0的个数,所以代码如下:
2015-02-05 17:33:07 757
原创 Reverse Integer
Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321click to show spoilers.Have you thought about this?Here are some good questions to ask before c
2015-02-04 21:24:57 346
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人