- 博客(78)
- 资源 (20)
- 收藏
- 关注
原创 Python学习笔记-小记
1.字符串string判断一个字符(char)是数字还是字母 str.isalpha #判断是否为字母str.isdigit #判断是否为数字判断一个字符串是否为空if not str.strip(): #判断是否为空,true表示空向字符串添加内容str = ''.join('love')得到字符串固定长度的字串str = str1[1:3] #得到从下标1开始到下标3之前的字符,下标3的字符不
2015-06-26 20:48:14 1271
原创 R语言-merge和rbind
rbind使用方式 合并两个数据集,要求两个数据集的列数相等:rbind(parameter1,parameter2)合并多个数据集,各个数据集的列数相等:rbind(parameter1,parameter2,...,parametern)从数据集中提取数据test <- rbind()for (i in 1:length(s_5)){ test <- rbind(test,dat
2015-06-15 10:37:44 41076
原创 Leetcode[120]-Triangle
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], [3,4], [6,5,7],
2015-06-14 17:03:43 1280
原创 C++ vector用法小记
最近在leetcode上面做题,STL的vector用的甚多,这里稍微的总结下vector的一些常用方法,包括一维的和二维的,暂时能想到的就给记下了。一维vector创建一维vector: vector<int> nums;//不指定长度vector<int> nums(n); // 指定长度为n 添加元素nums.push_back(1);//直接从数组末端添加nums[i] = 1;//直接
2015-06-14 13:51:21 5650 1
原创 Leetcode[63]-Unique Paths II
Follow up for “Unique Paths”:Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space is marked as 1 and 0 respectively in the grid.For ex
2015-06-14 13:29:34 948
原创 Leetcode[62]-Unique Paths
A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the botto
2015-06-14 12:59:05 1179
原创 Leetcode[70]-Climbing Stairs
You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?题意:给你一个n阶的台阶,你一次最多只能上2个台阶,请问一共有多少个走法?
2015-06-14 12:27:58 917
原创 Leetcode[198]-House Robber
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses
2015-06-14 11:18:29 1055
转载 化抽象为具体学动态规划
最近在看动态规划,这篇文章是0-1背包问题,看到这个具体化的例子真的讲的不错,收藏了,顺便附带了原文评论中的分析部分!原文地址:http://www.cnblogs.com/sdjl/articles/1274312.html对于动态规划,每个刚接触的人都需要一段时间来理解,特别是第一次接触的时候总是想不通为什么这种方法可行,这篇文章就是为了帮助大家理解动态规划,并通过讲解基本的01背包问题来引导读
2015-06-14 09:32:03 1128
原创 最长递增子序列长度算法
求最长连续子序列的长度,数字保存在数组中使用动态规划算法,理解状态转移,dp[i]表示i位置下的最大连续子序列长度。初始状态dp[0] = 1,表示在数组下标为0的时候,它的最长子序列长度就是1,接着从1开始从左到右扫描,如果后一个数大于前一个数,则它的最长子序列长度增加1,否则,此位置的最长子序列长度置为1,同时记录下当前的最大子序列长度;最后返回记录的最大连续子序列变量。代码如下:Cod
2015-06-13 22:15:15 1312
原创 Leetcode[215]-Kth Largest Element in an Array
Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.For example, Given[3,2,1,5,6,4]and k = 2, return 5.Note:
2015-06-13 20:58:12 1604
原创 Leetcode[114]-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: 1 \ 2
2015-06-13 13:01:06 1397
原创 Leetcode[103]-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 binary tree
2015-06-13 12:39:09 997
原创 Leetcode[98]-Validate Binary Search Tree
Validate Binary Search TreeGiven 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
2015-06-13 12:19:54 1035
原创 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,#,#,15,7}, 3
2015-06-13 11:08:55 1560
原创 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,#,#,15,7}, 3 / \ 9 20 / \ 1
2015-06-13 10:49:07 1279
原创 Leetcode[145]-Binary Tree Postorder Traversal
Given a binary tree, return the postorder traversal of its nodes’ values.For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3return [3,2,1].Note: Recursive solution is trivial, could
2015-06-13 10:10:29 1088
原创 Leetcode[144]-Binary Tree Preorder Traversal
Given a binary tree, return the preorder traversal of its nodes’ values.For example: Given binary tree{1,#,2,3}, 1 \ 2 / 3return [1,2,3].递归遍历:/**C++ * Definition for a binary tree n
2015-06-13 09:24:24 852
原创 Leetcode[9]-Palindrome Number
Determine whether an integer is a palindrome. Do this without extra space.Some hints: Could negative integers be palindromes? (ie, -1)If you are thinking of converting the integer to string, note the
2015-06-13 08:45:03 901
原创 Leetcode[7]-Reverse Integer
Reverse digits of an integer.Example1: x = 123, return 321 Example2: x = -123, return -321取一个数的最后一位,用x % 10,取一个数的前n-1位(共n位),用x/10,每一次取的时候,都将上一次取的数乘以10,然后再加上末尾的数即可,代码如下:Code(C++)class Solution {public
2015-06-12 23:09:40 999
原创 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 never differ by
2015-06-12 23:00:48 1068
原创 Leetcode[173]-Binary Search Tree Iterator
Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Calling next() will return the next smallest number in the BST.Note: next() and hasN
2015-06-12 22:34:58 700
原创 Leetcode[96]-Unique Binary Search Trees
Given n, how many structurally unique BST’s (binary search trees) that store values 1…n?For example, Given n = 3, there are a total of 5 unique BST’s. 1 3 3 2 1 \ /
2015-06-12 21:39:07 1666
原创 Leetcode[226]-Invert Binary Tree
Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1Trivia: This problem was inspired by this original tweet by Max Howell: Google:
2015-06-12 17:32:00 1640
原创 Leetcode[113]-Path Sum II
Given a binary tree and a sum, find all root-to-leaf paths where each path’s sum equals the given sum.For example: Given the below binary tree and sum = 22, 5 / \
2015-06-12 16:33:27 1809
原创 Leetcode[129]-Sum Root to Leaf Numbers
Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which represents the number 123.Find the total sum of al
2015-06-12 14:15:32 956
原创 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 the
2015-06-12 08:56:37 1013
原创 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 is symmetric: 1 / \ 2 2 / \ / \3 4 4 3But the following is not
2015-06-11 23:00:32 870
原创 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.递归法:/** * Definition for a binary tree nod
2015-06-11 22:23:13 970
原创 Leetcode[94]-Binary Tree Inorder Traversal
Given a binary tree, return the inorder traversal of its nodes’ values.For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3return[1,3,2].递归遍历法:/** * Definition for a binary tree node
2015-06-11 20:23:17 880
原创 Leetcode[100]-Same Tree
Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value.思路:递归法判断 假设两棵树根结点为
2015-06-11 18:16:33 859
原创 Leetcode[104]-Maximum Depth of Binary Tree
Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.求最大深度,用递归的方法/** * Definition for a binary
2015-06-11 17:17:45 866
原创 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 "()[]{}" are all valid but "
2015-06-11 14:45:26 837
原创 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 palindr
2015-06-11 14:12:35 929
原创 Leetcode[222]-Count Complete Tree Nodes
Given a complete binary tree, count the number of nodes.Definition of a complete binary tree from Wikipedia: In a complete binary tree every level, except possibly the last, is completely filled, and
2015-06-11 13:24:18 2137
原创 Leetcode[74]-Search a 2D Matrix
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted from left to right. The first integer of each row is
2015-06-11 12:18:43 714
原创 Leetcode[4]-Median of Two Sorted Arrays
There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).思路:先将两个数组合并,然后排序,最后找中位数中位数:若有n
2015-06-11 12:09:40 655
原创 Leetcode[154]-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 unknown to y
2015-06-11 11:04:25 804
原创 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 the array.方法一:直
2015-06-11 10:59:50 996
原创 Leetcode[162]-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 peaks, in that case
2015-06-11 10:56:12 1416
visio_2010_64位.part3.rar
2018-04-29
visio 2010 64 bit-part2
2018-04-29
visio 2010 64 bit-part1
2018-04-29
visio 2010 64 bit-part4
2018-04-29
决策树算法python实现
2015-05-25
python2.7.5安装及其相应的matplotlib的包及依赖
2015-05-25
jQuery+Struts+Ajax无刷新分页
2015-04-13
jasperreports-5.5.1_struts2.3整合用到的jar包
2014-05-28
php-5.3.6-Win32-VC9-x64.zip
2014-03-18
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人