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

原创 AddTwoNumbers
LeetCode 2 Add Two Numbers题目链接:https://leetcode.com/problems/add-two-numbers/description/You are given two non-empty linked lists representing two non-negative integers. The digits are stored in revers
2018-01-25 20:21:34
314
原创 2020-02-13
Anaconda安装tensorflow和keras总结1.最好安装python3.5或者3.6,使用Anaconda默认的python3.7,安装tensorflow时出现没有合适的版本错误-2. conda create -n tensorflow python=3.5 创建一个python3.5的环境,名为tensorflowactivate tensorflow进入tensorf...
2020-02-13 13:01:57
181
原创 LeetCode 63.Unique Paths II
LeetCode 63.Unique Paths IIFollow 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 res
2018-01-30 16:06:34
214
原创 LeetCode 62 Unique Paths
LeetCode 62 Unique Paths题目链接:https://leetcode.com/problems/unique-paths/description/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 m
2018-01-30 15:10:44
188
原创 LeetCode 64 .Minimum Path Sum
LeetCode 64 .Minimum Path Sum题目链接:https://leetcode.com/problems/minimum-path-sum/description/Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimiz
2018-01-30 14:40:56
218
原创 LeetCode 98.Validate Binary Search Tree
LeetCode 98.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 k
2018-01-30 13:15:46
207
原创 LeetCode 95.Unique Binary Search Trees II
LeetCode 95.Unique Binary Search Trees II题目链接:https://leetcode.com/problems/unique-binary-search-trees-ii/description/Given an integer n, generate all structurally unique BST’s (binary search trees) th
2018-01-30 12:20:32
201
原创 LeetCode 96.Unique Binary Search Trees
LeetCode 96.Unique Binary Search TreesGiven 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
2018-01-29 19:48:51
173
原创 LeetCode 69. Sqrt(x)
LeetCode 69. Sqrt(x)Implement int sqrt(int x).Compute and return the square root of x.x is guaranteed to be a non-negative integer.Example 1:Input: 4Output: 2Example 2:Input: 8Output: 2Explanation:
2018-01-29 16:01:06
261
原创 LeetCode 145. Binary Tree Postorder Traversal
LeetCode 145. Binary Tree Postorder TraversalGiven a binary tree, return the postorder traversal of its nodes’ values.For example: Given binary tree [1,null,2,3], 1 \ 2 / 3return [3
2018-01-29 14:53:54
188
原创 LeetCode 94. Binary Tree Inorder Traversal
LeetCode 94. Binary Tree Inorder TraversalGiven a binary tree, return the inorder traversal of its nodes’ values.For example: Given binary tree [1,null,2,3], 1 \ 2 / 3return [1,3,2]
2018-01-29 14:53:07
146
原创 LeetCode 144.Binary Tree Preorder Traversal
LeetCode 144.Binary Tree Preorder TraversalGiven a binary tree, return the preorder traversal of its nodes’ values.For example: Given binary tree [1,null,2,3], 1 \ 2 / 3return [1,2,
2018-01-29 14:51:58
137
原创 LeetCode 112 Path Sum
LeetCode 112 Path Sum题目来源:https://leetcode.com/problems/path-sum/description/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 pa
2018-01-28 21:06:45
170
原创 LeetCode 109. Convert Sorted List to Binary Search Tree
LeetCode 109. Convert Sorted List to Binary Search Tree题目来源:https://leetcode.com/problems/convert-sorted-list-to-binary-search-tree/description/Given a singly linked list where elements are sorte
2018-01-28 20:29:41
146
原创 LeetCode 108.Convert Sorted Array to Binary Search Tree
LeetCode 108.Convert Sorted Array to Binary Search Tree题目来源:https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/description/Given an array where elements are sorted in ascending or
2018-01-28 20:27:56
181
原创 LeetCode 110.Balanced Binary Tree
LeetCode 110.Balanced Binary TreeGiven 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 sub
2018-01-28 15:31:13
183
原创 LeetCode 101 Symmetric Tree
LeetCode Symmetric Tree题目来源 https://leetcode.com/problems/symmetric-tree/description/Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this bi
2018-01-27 17:03:11
188
原创 LeetCode 100 Same Tree
LeetCode 100 Same Tree题目来源:https://leetcode.com/problems/same-tree/description/Given two binary trees, write a function to check if they are the same or not.Two binary trees are considered the same if
2018-01-27 16:32:54
169
原创 LeetCode 53. Maximum Subarray
LeetCode 53. Maximum Subarray题目来源:https://leetcode.com/problems/maximum-subarray/description/Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For
2018-01-26 19:35:07
153
原创 LeetCode 33 Search in Rotated Sorted Array
LeetCode 33 Search in Rotated Sorted Array题目来源:https://leetcode.com/problems/search-in-rotated-sorted-array/description/Suppose an array sorted in ascending order is rotated at some pivot unknown to yo
2018-01-26 16:59:50
196
原创 Leetcode 81 Search in Rotated Sorted Array II
Leetcode 81 Search in Rotated Sorted Array II题目来源:https://leetcode.com/problems/search-in-rotated-sorted-array-ii/description/ Follow up for “Search in Rotated Sorted Array”: What if duplicates a
2018-01-26 16:57:50
142
原创 LeetCode 34. Search for a Range
LeetCode 34. Search for a Range题目来源:https://leetcode.com/problems/search-for-a-range/description/Given an array of integers sorted in ascending order, find the starting and ending position of a given t
2018-01-26 13:46:41
221
原创 LeetCode 35 Search Insert Position
LeetCode 35 Search Insert Position题目来源:https://leetcode.com/problems/search-insert-position/description/Given a sorted array and a target value, return the index if the target is found. If not, return
2018-01-25 20:49:50
218
原创 Longest Substring Without Repeating Characters
LeetCode 3. Longest Substring Without Repeating CharactersGiven a string, find the length of the longest substring without repeating characters.Examples:Given "abcabcbb", the answer is "abc", which the
2018-01-25 20:31:45
129
原创 155. Min Stack
155. Min Stack题目链接:https://leetcode.com/problems/min-stack/description/Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) – Push element x onto st
2018-01-25 20:28:45
166
转载 Java之"=="和equals的区别
转自:http://blog.youkuaiyun.com/qq_33406883/article/details/52180154 一、java当中的数据类型和“==”的含义:基本数据类型(也称原始数据类型) :byte,short,char,int,long,float,double,boolean。他们之间的比较,应用双等号(==),比较的是他们的值。 复合数据类型(类):当他们用(==)进行比较的时
2018-01-25 12:34:20
136
转载 JAVA之堆内存和栈内存的区别
Java把内存分成两种,一种叫做栈内存,一种叫做堆内存在函数中定义的一些基本类型的变量和对象的引用变量都是在函数的栈内存中分配。当在一段代码块中定义一个变量时,java就在栈中为这个变量分配内存空间,当超过变量的作用域后,java会自动释放掉为该变量分配的内存空间,该内存空间可以立刻被另作他用。 堆内存用于存放由new创建的对象和数组。在堆中分配的内存,由java虚拟机自动垃圾回收器来管理。在堆
2018-01-25 12:30:45
1537
原创 Count and Say
Count and SayThe count-and-say sequence is the sequence of integers with the first five terms as following:1. 12. 113. 214. 12115. 1112211 is read off as "one 1" or 11. 11 is r
2018-01-24 13:10:59
164
原创 20 Valid Parentheses
20 Valid ParenthesesGiven a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}"
2018-01-24 12:35:58
133
原创 Two Sum和Three Sum
Two Sum和Three Sum1.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 n
2018-01-24 12:29:20
322
原创 Longest Common Prefix
Longest Common PrefixWrite a function to find the longest common prefix string amongst an array of strings.方法一:public String longestCommonPrefix(String[] strs) { int n=strs.length,j;
2018-01-24 12:25:32
235
原创 Generate Parentheses卡特兰数的应用:
卡特兰数的应用:(1)n对括号正确匹配数目:给定n对括号,求括号正确配对的字符串数,例如:0对括号:[空序列] 1种可能1对括号:() 1种可能2对括号:()() (()) 2种可能3对括号:((())) ()(()) ()()() (())() (()()) 5种可能那么问题来了,n对括号有多少种正确配对的可能呢?考虑n对括号时的任意一种配对方案,最后一个右括号有唯一的与之匹配的左括号,于是有唯一
2018-01-24 12:23:39
182
原创 CircleList_2
Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Follow up: Can you solve it without using extra space?找出单链表中环开始的结点:(1)同Circle——List,使用快慢指针判断是否存在环,并找到两指针相遇
2018-01-04 21:06:15
248
原创 Circle_List
Given a linked list, determine if it has a cycle in it.Follow up: Can you solve it without using extra space?判断一个单链表中是否存在环:采用快慢指针方法,若慢指针和快指针中间相遇,则一定存在环。public class Circle_List { public boolean ha
2018-01-04 21:05:03
315
原创 Record_List
Recorder_Listhttps://www.nowcoder.com/questionTerminal/3d281dc0b3704347846a110bf561ef6bGiven a singly linked list L: L 0→L 1→…→L n-1→L n, reorder it to: L 0→L n →L 1→L
2018-01-04 21:04:04
1819
原创 sort_List
1.Sort a linked list in O(n log n) time using constant space complexity.使用合并排序对单链表进行排序,时间复杂度为O(nlogn),使用插入排序对单链表进行排序,时间复杂度为O(n2);public class Sort_list { public ListNode findMiddle(ListNode head){
2018-01-04 21:01:58
224
原创 remove-nth-node-from-end-of-list
Given a linked list, remove the n th 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
2018-01-04 21:00:57
521
原创 MergeTwoSortedList
合并两个有序链表:package leetcode;import java.util.List;public class MergeTwoSortedList { public ListNode MergeTwoSortedList(ListNode l1,ListNode l2) { // TODO Auto-generated constructor stub
2018-01-04 20:59:54
137
原创 替换空格:
替换空格:一含有空格的字符串,将字符串使用%20替代,“We are happy”,输出为:”We%20are%20happy”package 剑指offer;public class Test042 { public String replaceSpace(StringBuffer str){ int spacenum = 0;//spacenum为计算空格数
2017-11-24 12:13:05
153
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人