- 博客(206)
- 收藏
- 关注

转载 唐纳德·霍尔《踢树叶》
踢树叶唐纳德.霍尔一 踢树叶,十月里的一天,在安阿伯我们看完比赛,一起走回家,天色黑如煤炱,空中饱含雨意;我踢枫树的叶子,红的有七十种层次黄的像张旧报纸;杨树的叶子,既脆又白还有榆树叶,像注定要灭绝的种族的破旗我踢树叶,发出一种我熟悉的声音当树叶从我的靴前盘旋升起然后纷纷落下,于是我记起有几年的十月,在康涅狄格我走去上学穿
2015-12-26 19:23:02
1917
原创 297. 二叉树的序列化与反序列化
序列化是将一个数据结构或者对象转换为连续的比特位的操作,进而可以将转换后的数据存储在一个文件或者内存中,同时也可以通过网络传输到另一个计算机环境,采取相反方式重构得到原数据。请设计一个算法来实现二叉树的序列化与反序列化。这里不限定你的序列 / 反序列化算法执行逻辑,你只需要保证一个二叉树可以被序列化为一个字符串并且将这个字符串反序列化为原始的树结构。示例:你可以将以下二叉树: 1 / \ 2 3 / \ 4 5序列化为 "[1,2,3,null,...
2020-06-17 11:49:43
213
1
原创 572. 另一个树的子树
给定两个非空二叉树 s 和 t,检验 s 中是否包含和 t 具有相同结构和节点值的子树。s 的一个子树包括 s 的一个节点和这个节点的所有子孙。s 也可以看做它自身的一棵子树。示例 1:给定的树 s: 3 / \ 4 5 / \1 2给定的树 t: 4 / \1 2返回 true,因为 t 与 s 的一个子树拥有相同的结构...
2020-05-07 17:57:06
198
原创 Leetcode 42 接雨水
给定 n 个非负整数表示每个宽度为 1 的柱子的高度图,计算按此排列的柱子,下雨之后能接多少雨水。上面是由数组 [0,1,0,2,1,0,1,3,2,1,2,1] 表示的高度图,在这种情况下,可以接 6 个单位的雨水(蓝色部分表示雨水)。 感谢 Marcos 贡献此图。示例:输入: [0,1,0,2,1,0,1,3,2,1,2,1]输出: 6对于数组中的每个元素,我们找出下雨...
2020-04-05 00:07:09
178
原创 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 element. em...
2020-03-20 22:33:19
277
原创 LeetCode 657.Robot Return to Origin
There is a robot starting at position (0, 0), the origin, on a 2D plane. Given a sequence of its moves, judge if this robot ends up at (0, 0) after it completes its moves.The move sequence is repres...
2020-03-19 23:52:13
122
原创 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 absolute difference between i and j is at most k....
2020-03-18 16:43:16
155
原创 LeetCode 206. Reverse Linked List
Reverse a singly linked list.Example:Input: 1->2->3->4->5->NULLOutput: 5->4->3->2->1->NULLFollow up:A linked list can be reversed either iteratively or recursi...
2020-03-17 10:58:45
149
原创 LeetCode 203. Remove Linked List Elements
Remove all elements from a linked list of integers that have value val.Example:Input: 1->2->6->3->4->5->6, val = 6Output: 1->2->3->4->5//java/** * Definition...
2020-03-17 09:44:21
179
原创 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 house...
2020-03-16 10:46:25
106
原创 LeetCode 1295. Find Numbers with Even Number of Digits
Given an array nums of integers, return how many of them contain an even number of digits.Example 1:Input: nums = [12,345,2,6,7896]Output: 2Explanation: 12 contains 2 digits (even number of...
2020-03-15 23:39:41
765
原创 LeetCode 191. Number of 1 Bits
Write a function that takes an unsigned integer and returnthe number of '1'bits it has (also known as the Hamming weight).Example 1:Input: 00000000000000000000000000001011Output: 3Explanat...
2020-03-14 16:47:22
132
原创 LeetCode 172. Factorial Trailing Zeroes
Given an integer n, return the number of trailing zeroes in n!.Example 1:Input: 3Output: 0Explanation:3! = 6, no trailing zero.Example 2:Input: 5Output: 1Explanation:5! = 120, one trai...
2020-03-14 09:53:57
108
原创 LeetCode 169. Majority Element
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 alwa...
2020-03-13 16:52:55
207
原创 LeetCode 167. Two Sum II - Input array is sorted
Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers ...
2020-03-12 12:22:26
107
原创 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() -- Ge...
2020-03-11 12:57:50
160
原创 LeetCode 136. Single Number
Given a non-emptyarray 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 us...
2020-03-10 10:14:34
127
原创 LeetCode 125. Valid Palindrome
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.Note:For the purpose of this problem, we define empty string as valid palindrome.Examp...
2020-03-09 13:42:01
158
原创 LeetCode 122. Best Time to Buy and Sell Stock II
Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (i.e., buy on...
2020-03-08 12:30:36
133
原创 LeetCode 121. Best Time to Buy and Sell Stock
Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (i.e., buy one and sell one share of the stock),...
2020-03-07 09:17:25
104
原创 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.Note:A leaf is a node with no childre...
2020-03-06 14:27:14
106
原创 LeetCode 88. Merge Sorted Array
Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:The number of elements initialized in nums1 and nums2 are m and n respectively. You may assume tha...
2020-03-05 23:55:33
93
原创 LeetCode 53. Maximum Subarray
Given an integer array nums, find the contiguous subarray(containing at least one number) which has the largest sum and return its sum.Example:Input: [-2,1,-3,4,-1,2,1,-5,4],Output: 6Explanati...
2020-03-05 16:23:16
141
原创 LeetCode 804. Unique Morse Code Words
International Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes, as follows: "a" maps to ".-", "b" maps to "-...", "c" maps to "-.-.", and so on.For c...
2019-07-31 16:05:46
169
原创 LeetCode 279. Perfect Squares
Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n.Example 1:Input: n = 12Output: 3 Explanation: 12 = 4 + 4 + 4.Example...
2019-06-26 14:42:50
226
原创 LeetCode 1021. Remove Outermost Parentheses
A valid parentheses string is either empty (""), "(" + A + ")", or A + B, where A and B are valid parentheses strings, and + represents string concatenation. For example, "", "()", "(())()", and "(()...
2019-06-24 23:02:04
193
原创 LeetCode 27. Remove Element
Given an array nums and a value val, 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 by modifying the input arra...
2019-06-23 22:53:12
143
原创 LeetCode 709. To Lower Case
Implement function ToLowerCase() that has a string parameter str, and returns the same string in lowercase.Example 1:Input: "Hello"Output: "hello"Example 2:Input: "here"Output: "here"...
2019-06-11 13:23:23
147
原创 LeetCode 938. Range Sum of BST
Given the root node of a binary search tree, return the sum of values of all nodes with value between L and R (inclusive).The binary search tree is guaranteed to have unique values.Example 1:...
2019-06-10 17:32:19
254
原创 LeetCode 771. Jewels and Stones
You're given strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in S is a type of stone you have. You want to know how many of the sto...
2019-06-10 16:13:25
84
原创 LeetCode 26. Remove Duplicates from Sorted Array
Given a sorted array nums, 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 by modifyi...
2019-06-05 23:12:07
84
原创 LeetCode 21. Merge Two Sorted Lists
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.Example:Input: 1->2->4, 1->3->4Output: 1-...
2019-06-04 23:14:56
75
原创 LeetCode 20. Valid Parentheses
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.An input string is valid if:Open brackets must be closed by the same type of b...
2019-05-29 15:10:50
75
原创 LeetCode 14. Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings.If there is no common prefix, return an empty string "".Example 1:Input: ["flower","flow","flight"]Output:...
2019-05-28 23:08:05
82
原创 LeetCode 13. Roman to Integer
Roman numerals are represented by seven different symbols:I, V, X, L, C, D and M.Symbol ValueI 1V 5X 10L 50C 100D ...
2019-05-28 15:50:01
209
原创 Spring MVC 和 Spring 总结
1. 为什么使用Spring ? 1). 方便解耦,简化开发 通过Spring提供的IoC容器,可以将对象之间的依赖关系交由Spring进行控制,避免硬编码所造成的过度程序耦合。 2). AOP编程的支持 通过Spring提供的AOP功能,方便进行面向切面的编程,如性能监测、事务管理、日志记录等。 3). 声明式事务的支持...
2019-05-27 12:06:14
89
原创 C++产生随机数
函数一:int rand(void);从srand (seed)中指定的seed开始,返回一个 ( seed, RAND_MAX(0x7fff))间的随机整数。函数二:void srand(unsigned seed);参数seed是rand()的种子,用来初始化rand()的起始值。大致过程如下:rand()在每次被调用的时,它会查看:(1)如果用户在此之前调用过...
2019-05-19 22:21:41
13798
1
原创 LeetCode 7. Reverse Integer
Given a 32-bit signed integer, reverse digits of an integer.Example 1:Input: 123Output: 321Example 2:Input: -123Output: -321Example 3:Input: 120Output: 21Note:Assume we are dea...
2019-04-21 01:34:51
85
原创 LeetCode 3. Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring without repeating characters.Example 1:Input: "abcabcbb"Output: 3 Explanation: The answer is "abc", with the length of 3. Example 2:...
2019-04-17 16:53:13
88
原创 LeetCode 2. Add Two Numbers
You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return i...
2019-04-16 00:35:17
232
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人