自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

cindy_niu的专栏

记录学习的点滴

  • 博客(140)
  • 收藏
  • 关注

原创 Django静态文件处理【开发环境】

问题描述: Django中需要嵌入一张图片,但是直接使用相对路径查找,无法显示图片。 【初始路径设置,图片放在images文件夹下】 解决办法: 官方文档:Managing static files (CSS, images)django中处理css,js, images文件分为两种情况:开发环境和生产环境。本文介绍开发环境下的实现步骤。查阅了很多资料和博客,一种方法是在urls.py中设置一

2015-05-11 16:12:34 1973

原创 【算法】跨越式搜索之数组查找

题目1:给出一个一维数组A, 大小为n, 相邻元素的差的绝对值都为1. 如A = [1, 0, 1, 2, 3, 2, 1, 2, 3],现在给定A和目标查找数num. 请找到num在数组中的位置。 题目2:在题目一的前提下,现在要返回num的所有索引位置。思路:依次遍历可以实现,但是复杂度O(N). 如果数组第一个元素是A[0], 要找的数是num. 设 t = abs(num - A[0]

2015-04-27 17:46:16 785

转载 快速掌握一个语言最常用的50%

文章链接:快速掌握一个语言最常用的50% 现在的开发工作要求我们能够快速掌握一门语言。一般来说应对这种挑战有两种态度:其一,粗粗看看语法,就撸起袖子开干,边查Google边学习;其二是花很多时间完整地把整个语言学习一遍,做到胸有成竹,然后再开始做实际工作。然而这两种方法都有弊病。第二种方法的问题当然很明显,不仅浪费了时间,偏离了目标,而且学习效率不高。因为没有实际问题驱动的语言学习通常是不牢固不深

2015-04-25 18:50:23 689

原创 [Django框架学习] URLconf的映射和模版继承

学习目标:实现一个web app, 可以识别人脸表情,识别算法在后台实现。 学习参考资料:The Django Book 2.0 – 中文版 后面会辅助:Django Documentation, 基础例子简单,但是不利于初学者理解框架的实现机制。整理一下django框架开发web 应用的核心机制: 一、MVC模式: Django很好地把分工不同的模块剥离开来,一个典型的框架包括这几个文件

2015-04-18 20:17:44 2371

原创 [C++]LeetCode: 133 Largest Rectangle in Histogram(最大矩形面积)

题目:Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.Above is a histogram where

2015-02-04 21:01:20 2874

原创 [C++]LeetCode: 132 Find Minimum in Rotated Sorted Array II (二分查找)

题目: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.The array may contain duplicate

2015-02-04 15:15:10 866

原创 [C++]LeetCode: 131 Trapping Rain Water (双边扫描)

题目:Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.For example, Given [0,1,0,2,1,0,1,3,2

2015-02-04 10:30:10 1124

原创 [C++]LeetCode: 130 Word Ladder (BFS)

题目:Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that:Only one letter can be changed at a timeEach intermediate

2015-01-28 21:18:11 1616

原创 [C++]LeetCode: 129 Clone Graph (图的深拷贝 BFS && DFS)

题目:Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.OJ's undirected graph serialization:Nodes are labeled uniquely.We use # as a separator f

2015-01-28 16:52:54 2875

原创 [C++]LeetCode: 128 Largest Number (自定义比较函数排序)

题目:Given a list of non negative integers, arrange them such that they form the largest number.For example, given [3, 30, 34, 5, 9], the largest formed number is 9534330.Note: The result

2015-01-28 10:51:20 6381 2

原创 [C++]LeetCode: 127 Sort Colors (计数排序 & 快速排序)

题目:Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use the in

2015-01-27 13:14:26 2291

原创 [C++]LeetCode: 126 Insertion Sort List (插入排序链表)

题目:Sort a linked list using insertion sort.思路:题目要求我们用插入排序来实现链表排序。我们构建一个当前排好序的链表,然后维护一个变量,不断指向链表中的下一个节点。用变量cur表示当前要插入的节点,每次循环找到cur节点在当前排好序的链表中对应的位置,然后插入进去,然后指向原链表中下一个节点,继续进行插入过程,直到原链表的所有节点都完成,既经过

2015-01-27 11:20:52 1627 1

原创 [C++]LeetCode: 125 Sort List (归并排序链表)

题目:Sort a linked list in O(n log n) time using constant space complexity.思路:题目要求我们使用常数空间复杂度,时间复杂度为O(nlog(n)). 满足这个时间复杂度的有快速排序,归并排序,堆排序。插入排序时间复杂度为O(n^2). 双向链表用快排比较合适,堆排序也可用于链表,单项链表适合于归并排序。我们就用归并排序的

2015-01-27 10:30:17 2511

原创 [C++]LeetCode: 124 Populating Next Right Pointers in Each Node II(链接二叉树)

题目:Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your previous solution still work?Note:You may only use co

2015-01-26 12:49:34 724

原创 [C++]LeetCode: 123 Populating Next Right Pointers in Each Node(链接完全二叉树)

题目:Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointer to point to its next right

2015-01-26 10:13:16 882

原创 [C++]LeetCode: 122 Validate Binary Search Tree (是否是合法BST树)

题目:Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keys less than the node

2015-01-25 17:01:28 1241

原创 [C++]LeetCode: 121 Palindrome Partitioning (分割回文子串 回溯法)

题目:Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For example, given s = "aab",Return [

2015-01-25 15:57:02 1833

原创 [C++]LeetCode: 120 Permutations II

题目:Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2] have the following unique permutations:[1,1,2], [1,2,1], and [

2015-01-25 10:50:27 822

原创 [C++]LeetCode: 119 Gas Station

题目:There are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from statio

2015-01-23 17:19:17 639

原创 [C++]LeetCode: 118 Find Peak Element (二分查找 寻找数组局部峰值)

题目:A peak element is an element that is greater than its neighbors.Given an input array where num[i] ≠ num[i+1], find a peak element and return its index.The array may contain multiple pea

2015-01-23 15:45:46 5289

原创 [C++]LeetCode: 117 Simplify Path (简化Unix路径 list双向链表)

题目:Given an absolute path for a file (Unix-style), simplify it.For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c"click to show corner cases.Corner Cases:

2015-01-23 11:03:51 2867

原创 [C++]LeetCode: 116 Excel Sheet Column Number (excel列坐标转数字)

题目: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-01-23 09:44:50 1640

原创 [C++]LeetCode: 115 Permutations (求一组数的全排列)

题目:Given a collection of numbers, return all possible permutations.For example,[1,2,3] have the following permutations:[1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], and [3,2,1].Answer 1

2015-01-20 21:34:44 3556

原创 [C++]LeetCode: 114 Permutation Sequence(返回第k个阶乘序列——寻找数学规律)

题目:The set [1,2,3,…,n] contains a total of n! unique permutations.By listing and labeling all of the permutations in order,We get the following sequence (ie, for n = 3):"123""132""213"

2015-01-20 20:48:30 1327

原创 [C++]LeetCode: 113 Word Break II (DP && Backtacking) 求解拆分组合

题目:Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word.Return all such possible sentences.For example, given

2015-01-20 19:19:55 957

原创 [C++]LeetCode: 112 Word Break(DP)

题目:Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.For example, givens = "leetcode",dict =

2015-01-20 11:05:31 1778 1

原创 [C++]LeetCode: 111 Spiral Matrix II (螺旋写入矩阵)

题目:Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.For example,Given n = 3,You should return the following matrix:[ [ 1, 2, 3 ], [ 8, 9,

2015-01-19 17:12:26 820

原创 [C++]LeetCode: 110 Spiral Matrix (螺旋输出矩阵元素)

题目:Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.For example,Given the following matrix:[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ]

2015-01-19 16:28:56 2717 1

原创 [C++]LeetCode: 109 Swap Nodes in Pairs (交换相邻节点位置)

题目:Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant s

2015-01-18 17:41:36 888

原创 [C++]LeetCode: 108 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

2015-01-18 17:15:23 1792

原创 [C++]LeetCode: 107 Reverse Words in a String (2014腾讯实习笔试题)

题目:Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".click to show clarification.Clarification:What co

2015-01-18 12:40:10 941

原创 [C++]LeetCode: 106 Convert Sorted List to Binary Search Tree (有序链表转AVL树)

题目:Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.思路:这道题的解题思路和Convert Sorted Array to Binary Search Tree (AVL树)一样。我们也是找到有序链表的中间节点作

2015-01-17 18:52:08 1105

原创 [C++]LeetCode: 105 Longest Substring Without Repeating Characters

题目:Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is

2015-01-17 15:27:42 633

原创 [C++]LeetCode: 104 Jump Game II (局部最优和全局最优法)

题目:Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Your

2015-01-17 12:45:11 1259

原创 [C++]LeetCode: 103 Jump Game (局部最优和全局最优法)

题目:Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Dete

2015-01-17 12:13:13 1670

原创 [C++]LeetCode: 102 Flatten Binary Tree to Linked List (二叉树转前序链表)

题目:Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened tree should look like:

2015-01-16 18:59:48 782

原创 [C++]LeetCode: 101 Binary Tree Zigzag Level Order Traversal

题目:Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).For example:Given

2015-01-16 15:55:48 1026

原创 [C++]LeetCode: 100 Convert Sorted Array to Binary Search Tree (AVL树)

题目:Given an array where elements are sorted in ascending order, convert it to a height balanced BST.思路:给出一个排序的数组,如何构造一个平衡二叉查找树?平衡二叉查找树要求任一结点的左右子树的高度差不能超过一,也叫做高度平衡树。如果让我们从一个排序数组中选取一个元素做树的根,我们会选择哪一个

2015-01-16 14:49:17 1005

原创 [C++]LeetCode: 99 Longest Palindromic Substring (最长回文子串)

题目:Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring.思路:题目要求的s的一个最长回

2015-01-15 21:21:03 840

原创 [C++]LeetCode: 98 Evaluate Reverse Polish Notation

题目:Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or another expression.Some examples: ["2"

2015-01-15 18:50:16 661

空空如也

空空如也

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

TA关注的人

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