自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(25)
  • 收藏
  • 关注

转载 Spring中 @Autowired注解与@Resource注解的区别

原博客地址:(http://qiangmzsx.blog.51cto.com/2052549/1359952)Spring中 @Autowired注解与@Resource注解的区别在Spring 3.X中经常使用到@Autowired和@Resource进行装配。 不禁好奇这两个注解的差异在何处???相同点: @Resource的作用相当于@Autowired,均可标注在字段或属性的setter

2017-09-07 10:37:31 363

原创 LeetCode 226. Invert Binary Tree(Python)

题目描述: Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1思路: 运用递归前序遍历二叉树来实现交换AC代码:class Solution(object): def invertTree(self,

2017-08-27 14:42:43 442

原创 LeetCode 198. House Robber(Python)

题目描述: 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

2017-08-25 20:22:50 612

原创 LeetCode 169. Majority Element(Python)

题目描述: Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the majority element

2017-08-25 19:58:41 435

原创 LeetCode 114. Flatten Binary Tree to Linked List(Python)

题目描述: 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 \ 3 \ 4

2017-08-21 22:10:01 1085

原创 LeetCode 102. Binary Tree Level Order Traversal(Python)

题目描述: 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 / \ 9

2017-08-20 16:40:43 315

原创 LeetCode 101. Symmetric Tree(Python)

题目描述: 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 / \ / \3

2017-08-19 21:46:24 283

原创 LeetCode 64. Minimum Path Sum(Python)

题目描述: Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note: You can only move either down or right

2017-08-19 15:19:13 471

原创 LeetCode 59. Spiral Matrix II(Python)

题目描述: 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

2017-08-18 21:32:02 892

原创 LeetCode 98. Validate Binary Search Tree (Python)

题目描述: 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’s key. Th

2017-08-15 21:36:20 297

原创 LeetCode 78. Subsets (Python)

题目描述: Given a set of distinct integers, nums, return all possible subsets.Note: The solution set must not contain duplicate subsets.For example, If nums = [1,2,3], a solution is: [ [3], [1],

2017-08-13 21:16:47 523

原创 LeetCode 70. Climbing Stairs (Python)

题目描述: 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?Note: Given n will be a positi

2017-08-09 19:17:24 653

原创 LeetCode 63. Unique Paths II (Python)

题目描述: 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

2017-08-08 21:36:40 1125

原创 LeetCode 62. Unique Paths (Python)

题目描述: 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 th

2017-08-08 20:19:50 1586

原创 LeetCode 56. Merge Intervals (Python)

题目描述: Given a collection of intervals, merge all overlapping intervals.For example: Given [1,3],[2,6],[8,10],[15,18], return [1,6],[8,10],[15,18].AC代码:class Solution(object): def merge(self, int

2017-08-07 19:26:00 808

原创 LeetCode 49. Group Anagrams (Python)

题目描述: Given an array of strings, group anagrams together.For example, given: [“eat”, “tea”, “tan”, “ate”, “nat”, “bat”], Return:[ ["ate", "eat","tea"], ["nat","tan"], ["bat"]]Note: All inputs

2017-08-05 19:28:54 1872

原创 LeetCode 34. Search for a Range (Python)

题目描述: Given an array of integers sorted in ascending order, find the starting and ending position of a given target value.Your algorithm’s runtime complexity must be in the order of O(log n).If the ta

2017-08-02 16:53:02 1121

原创 LeetCode 24. Swap Nodes in Pairs (Python)

题目描述: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 space. You ma

2017-07-31 21:40:14 315

原创 LeetCode 19. Remove Nth Node From End of List (Python)

题目描述: 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 the end, the linked

2017-07-30 22:28:59 312

原创 LeetCode 11. Container With Most Water (Python)

题目描述: Given n non-negative integers a1, a2, …, an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find

2017-07-28 20:27:53 452

转载 KNN算法(基于KD-Tree)

输入数据可以自己调,设置要查的point和k值后返回最邻近的k个pointimport numpy as npclass KD_Node: def __init__(self, point=None, split=None, leftNode=None, rightNode=None): """ :param point:数据点 :param

2017-07-19 20:34:24 664

原创 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?AC代码:class Solution(object): def isPalindrome(self, head): """

2017-07-16 17:21:25 202

原创 LeetCode 7.Reverse Integer

题目描述:Reverse digits of an integer.Example1: x = 123, return 321 Example2: x = -123, return -321Note: The input is assumed to be a 32-bit signed integer. Your function should return 0 when the reverse

2017-07-12 15:47:27 376

原创 LeetCode 16.3Sum Closest

题目描述:Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exa

2017-07-12 15:17:58 243

原创 LeetCode 1.Two Sum (Python)

题目描述: Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use the s

2017-07-12 15:13:45 278

空空如也

空空如也

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

TA关注的人

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