- 博客(10)
- 收藏
- 关注
原创 Ubuntu安装JDK后,再次打开终端失效--已解决
今天在给Ubuntu配置JDK后,发现了一个问题,再次打开终端后,输入java -version命令,显式未安装JDK。经过在网上查阅资料和自己思考,现在总结问题如下:1.在安装JDK时,因为权限的原因,是以root用户进行操作的,再次开发终端后,是以普通用户的身份运行。2.配置环境变量时,以gedit方式打开,而不是vim。3.编辑环境变量后,执行source命令,root用户已经配置,但是对普...
2018-05-14 22:57:28 2746 1
转载 Morris Traversal方法遍历二叉树(非递归,不用栈,O(1)空间)
在leetcode中有一道题目是recover binary search tree,要求使用O(1)的空间复杂度,需要使用二叉线索树,重新学习这个数据结构知识点。本文主要解决一个问题,如何实现二叉树的前中后序遍历,有两个要求:1. O(1)空间复杂度,即只能使用常数空间;2. 二叉树的形状不能被破坏(中间过程允许改变其形状)。通常,实现二叉树的前序(preorder)、中序(inorder)、后...
2018-04-18 14:53:44 113
原创 leetcode.115. Distinct Subsequences
题目描述:Given a string S and a string T, count the number of distinct subsequences of S which equals T.A subsequence of a string is a new string which is formed from the original string by deleting some ...
2018-04-10 15:15:42 121
原创 leetcode.652. Find Duplicate Subtrees
Given a binary tree, return all duplicate subtrees. For each kind of duplicate subtrees, you only need to return the root node of any oneof them.Two trees are duplicate if they have the same structure...
2018-04-09 16:06:58 282
原创 leetcode.611. Valid Triangle Number
Given an array consists of non-negative integers, your task is to count the number of triplets chosen from the array that can make triangles if we take them as side lengths of a triangle.Example 1:Inp...
2018-04-04 10:48:46 89
原创 leetcode.560. Subarray Sum Equals K
Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k.Example 1:Input:nums = [1,1,1], k = 2Output: 2Note:The length of the arra...
2018-04-04 09:47:40 85
转载 最长公共子序列(LCS)&&最长公共子串 &&最长递增子序列(LIS)
讲解的非常好,从别人的别克转载的虽是读书笔记,但是如转载请注明出处 http://segmentfault.com/blog/exploring/.. 拒绝伸手复制党本章讲解:1. LCS(最长公共子序列)O(n^2)的时间复杂度,O(n^2)的空间复杂度;2. 与之类似但不同的最长公共子串方法。最长公共子串用动态规划可实现O(n^2)的时间复杂度,O(n^2)的空间复杂度;还可以进一步优化,用后...
2018-04-03 10:37:00 441
原创 leetcode.238. Product of Array Except Self
Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i].Solve it without division and in O(n).F...
2018-04-01 16:45:27 92
原创 leetcode.448. Find All Numbers Disappeared in an Array
Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements of [1, n] inclusive that do not appear in this array.Could yo...
2018-04-01 15:37:36 84
原创 leetcode.442. Find All Duplicates in an Array
题目:Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements that appear twice in this array.Could you do it without extra s...
2018-04-01 14:33:39 73
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人