自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

小拳头的博客

临渊羡鱼、不如退而结网

  • 博客(70)
  • 资源 (1)
  • 收藏
  • 关注

原创 c++ vector, set, map的用法总结

一、vector 向量容器(1)头文件 #include(2)创建vector对象, vector vec;vector的元素不仅仅可以是int, double, string,还可以是结构体,但是要注意:结构体要定义为全局的,否则会出错。(3)基本操作:cout使用下标访问元素,和数组一样下标从0

2016-06-03 15:16:51 14687 1

原创 Django搭建简易博客教程(二)

十一、View和URL网页程序的逻辑:request进来 -> 从服务器获取数据 -> 处理数据 -> 把网页呈现出来url 设置相当于客户端向服务器发出request请求的入口,并用来指明要调用的程序逻辑views 用来处理程序逻辑,然后呈现到template(一般为GET方法,POST方法略有不同)template 一般为html+CSS的形式,主要是呈现给用户

2016-06-30 20:26:20 2024

原创 Django搭建简易博客教程(一)

一、准备工作windows 7 系统python 2.7 环境已在windows配置好django环境,若还未配置好,请参照文章:http://blog.csdn.net/xiaoquantouer/article/details/51656520 进行配置二、创建新项目在工程目录下打开命令框,运行以下指令:$ django-admin startp

2016-06-30 18:11:37 1205

原创 【leetcode】67. Add Binary

一、题目描述Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".题目解读:给两个二进制字符串,算出相加后的结果思路:注意进位的情况。原理都懂,但是简洁的代码不好写。这里参考了别人的

2016-06-30 14:22:11 308

原创 【leetcode】14. Longest Common Prefix

一、题目描述Write a function to find the longest common prefix string amongst an array of strings.题目解读:有一个字符串的容器,判断容器中所有字符串的最长公共前缀字符串思路:以容器中第一个字符串为标志,遍历该字符串中每个字符,然后从后面的字符串中的相同位置,判断是否与第一个字符串的

2016-06-29 22:54:29 281

原创 【leetcode】234. 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?题目解读:判断一个链表是否是回文的思路:要实现时间复杂度为o(n),空间复杂度为o(1)想了很久,确实不太好实现

2016-06-28 20:20:46 329

原创 python读取excel文件

一、读excelimport xlrddef open_excel(filename): # 打开文件 xlrd.Book.encoding = "urf-8" try: data = xlrd.open_workbook(filename) return data except Exception, e: print str(e)def excel_tab

2016-06-28 11:24:05 903

原创 【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 --> 5题目描述:给一个链表

2016-06-27 23:09:47 226

原创 【leetcode】58. 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.Not

2016-06-26 15:52:31 279

原创 【leetcode】257. Binary Tree Paths

一、题目描述Given a binary tree, return all root-to-leaf paths.For example, given the following binary tree: 1 / \2 3 \ 5All root-to-leaf paths are:["1->2->5", "1->3"

2016-06-26 15:37:00 241

原创 【leetcode】38. 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

2016-06-26 11:12:54 301

原创 【leetcode】20. Valid Parentheses

一、题目描述Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" 

2016-06-25 15:05:49 330

原创 【leetcode】19. Remove Nth Node From End of List

一、题目描述Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from

2016-06-24 17:51:46 242

原创 【leetcode】88. Merge Sorted Array

一、题目描述Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:You may assume that nums1 has enough space (size that is greater or equal to m + n) t

2016-06-24 16:46:44 261

原创 【leetcode】205. Isomorphic Strings

一、题目描述Given two strings s and t, determine if they are isomorphic.Two strings are isomorphic if the characters in s can be replaced to get t.All occurrences of a character must be replac

2016-06-24 11:40:12 316

原创 【leetcode】160. Intersection of Two Linked Lists

一、题目描述Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a1 → a2 ↘

2016-06-24 11:16:36 297

原创 【leetcode】219. Contains Duplicate II

一、题目描述Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j]and the difference between i and j is at mo

2016-06-24 10:24:50 312

原创 【leetcode】223. Rectangle Area

一、题目解读Find the total area covered by two rectilinear rectangles in a 2D plane.Each rectangle is defined by its bottom left corner and top right corner as shown in the figure.Assume t

2016-06-23 21:27:00 384

原创 c++从int转string、char的方法总结

一、int to string(整型到字符串)(1)函数:int sprintf(char *buffer, const char *format [, argument] ...);头文件:#include例子:#include#includeusing namespace std;int main(){ int ss; char temp[64];

2016-06-23 20:50:33 35418 3

原创 【leetcode】299. Bulls and Cows

一、题目描述You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time your friend makes a guess, you prov

2016-06-21 17:41:36 309

原创 【leetcode】225. Implement Stack using Queues

一、题目描述Implement the following operations of a stack using queues.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top() -- Get the top element.empty() --

2016-06-21 16:46:51 234

原创 c++ STL学习之queue队列总结

一、头文件#include二、定义特点:先进先出三、用法(1)创建一个空的queue对象queue q(2)入队,将x接到队列的末端q.push(x)(3)出队,弹出队列的第一个元素,并不会返回被弹出元素的值q.pop()(4)访问队首元素(即最高被压入队列的元素)q.front()(5)访问队尾元

2016-06-21 14:32:48 635

原创 【leetcode】111. Minimum Depth of Binary Tree

一、题目描述Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.题目解读:给了一棵二叉树,求最小深度。最

2016-06-21 14:21:32 264

原创 【leetcode】112. 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 t

2016-06-21 11:12:16 187

原创 【leetcode】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

2016-06-21 10:33:12 256

原创 回文数算法

一、概念一个正数如果顺着和反过来都是一样的(比如12321,反过来也是12321),那么就称为回文数。注意:(1)回文数不能以0开头。   (2)回文数从1开始。二、初始想法写一个循环算出逆序的值,判断原序和逆序是否相等。这种思路可以算出正确结果,但是随着N的增大,效率太低。三、回文数算法发现回文数的个数的规律,如下:

2016-06-21 09:36:52 21418

原创 【leetcode】119. 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?

2016-06-17 11:10:02 197

原创 【leetcode】172. 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的个数。解决方法的时间复杂度在log(n)内。思路:说实话

2016-06-16 16:00:09 237

原创 【leetcode】102. Binary Tree Level Order Traversal

一、题目描述Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree [3,9,20,null,null,15,7], 3

2016-06-16 15:38:59 175

原创 【leetcode】26. 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 i

2016-06-16 11:10:12 211

原创 【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]]题目解读:给出行数,返回

2016-06-15 17:13:48 482

原创 【leetcode】232. Implement Queue using Stacks

一、题目描述Implement the following operations of a queue using stacks.push(x) -- Push element x to the back of queue.pop() -- Removes the element from in front of queue.peek() -- Get the front el

2016-06-15 15:34:41 361

原创 c++ STL学习之stack堆栈总结

一、头文件# include二、定义堆栈是一个线性表,插入和删除只在表的一端进行。这一端称为栈顶,另一端称为栈底。堆栈的元素插入称为入栈,元素的删除则为出栈。堆栈是一个后进先出表。三、用法(1)创建一个空的stack对象stack s;(2)元素入栈void push(const value_type& x)在栈顶添加元素

2016-06-15 15:04:06 6114

原创 【leetcode】107. Binary Tree Level Order Traversal II

一、题目描述Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For example:Given binary tree [3,9,20

2016-06-15 11:39:35 281

原创 【leetcode】342. Power of Four

一、题目描述Given an integer (signed 32 bits), write a function to check whether it is a power of 4.Example:Given num = 16, return true. Given num = 5, return false.Follow up: Could you solv

2016-06-15 11:25:23 343

原创 【leetcode】101. Symmetric Tree

一、题目描述Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree [1,2,2,3,4,4,3] is symmetric: 1 / \ 2 2 / \ / \

2016-06-15 10:50:43 266

原创 【leetcode】66. 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.题目描述:一

2016-06-15 10:32:39 238

原创 【leetcode】27. 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

2016-06-13 16:19:55 320

原创 【leetcode】110. 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

2016-06-13 15:38:00 305

原创 windows中Django安装教程

一、下载python下载地址:https://www.python.org/downloads/Django下载地址:https://www.djangoproject.com/download/二、安装默认已经安装了Python,这里就只将django的安装(1)下载django压缩包后,解压并且将文件夹放入python的安装目录中,然后进入d

2016-06-13 11:34:58 7171

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除