- 博客(74)
- 资源 (1)
- 收藏
- 关注
原创 Ubuntu14.04 无密码ssh localhost
1、安装ssh直接 sudo apt-get install openssh-server2、查看ssh运行状态 ps -e | grep ssh如果发现 sshd 和 ssh-agent 即表明 ssh服务基本运行正常3、生成公钥和私钥ssh-keygen -t rsa -P ""4、将公钥追加到文件cat ~/.ssh/id_rs
2016-04-15 10:15:55
584
原创 排序算法分析(JAVA)
参考:http://www.cnblogs.com/liuling/p/2013-7-24-01.html内排序有可以分为以下几类: (1)、插入排序:直接插入排序、二分法插入排序、希尔排序。 (2)、选择排序:简单选择排序、堆排序。 (3)、交换排序:冒泡排序、快速排序。 (4)、归并排序 (5)、基数排序这里分析1——4,下次有
2016-04-05 15:00:07
330
原创 Leetcode: 8. String to Integer (atoi)(JAVA)
【问题描述】Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possi
2016-03-22 11:23:43
400
原创 Leetcode: 165. Compare Version Numbers(JAVA)
【问题描述】Compare two version numbers version1 and version2.If version1 > version2 return 1, if version1 version2 return -1, otherwise return 0.You may assume that the version strings are non-
2016-03-22 10:46:37
481
原创 Leetcode:189. Rotate Array(JAVA)
【问题描述】Rotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4].Note:Try to come up as many sol
2016-03-21 16:31:54
971
原创 Leetcode: 168. Excel Sheet Column Title(JAVA)
【问题描述】Given a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA 28 -> AB
2016-03-21 16:10:35
1048
原创 Leetcode:278. First Bad Version(JAVA)
【问题描述】You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed
2016-03-20 16:03:36
492
原创 Leetcode: 125. Valid Palindrome(JAVA)
【问题描述】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 ca
2016-03-20 15:37:26
406
原创 Leetcode: 6. ZigZag Conversion(JAVA)
【问题描述】The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H
2016-03-19 13:18:58
266
原创 Leetcode:228. Summary Ranges(JAVA)
【问题描述】Given a sorted integer array without duplicates, return the summary of its ranges.For example, given [0,1,2,4,5,7], return ["0->2","4->5","7"].【思路】维护两个指针,start与end,如果nums[end+1]
2016-03-18 21:34:58
338
原创 Leetcode:204. Count Primes(JAVA)
【问题描述】Description:Count the number of prime numbers less than a non-negative number, n.【思路】方法1:非常粗暴的方法,判断每个数是否是素数,并计数。但是会出现Time Limit Exceeded错误。代码没有调试,可能有问题。 public static int count
2016-03-18 21:13:18
397
原创 Leetcode:303. Range Sum Query - Immutable(JAVA)
【问题描述】Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.Example:Given nums = [-2, 0, 3, -5, 2, -1]sumRange(0, 2) -> 1sumRange(2, 5)
2016-03-18 19:59:01
333
原创 Leetcode:28. Implement strStr()(JAVA)
【问题描述】Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.【思路】本题的目的其实是实现函数String.indexof()即:return haystack.inde
2016-03-18 17:04:54
474
原创 Leetcode:67. Add Binary(JAVA)
【问题描述】Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".【思路】从string的最高位开始相加,设置进位。【code】public class Solution { publi
2016-03-18 16:25:08
651
原创 Leetcode:234. Palindrome Linked List(JAVA)
【问题描述】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?【思路】1、利用栈,将list前半段入栈,然后后半段依次比较出栈。时间复杂度O(N),空间复杂度O(N/2)。2、将栈的后半
2016-03-16 21:19:03
1865
原创 Leetcode:257. Binary Tree Paths(JAVA)
【问题描述】Given a binary tree, return all root-to-leaf paths.For example, given the following binary tree: 1 / \2 3 \ 5All root-to-leaf paths are:["1->2->5", "1->3"
2016-03-16 20:21:20
456
原创 Leetcode:14. Longest Common Prefix(JAVA)
【问题描述】Write a function to find the longest common prefix string amongst an array of strings.Subscribe to see which companies asked this question【思路】求最长公共前缀长度。每次string元素与prefix比较,
2016-03-16 19:28:12
275
原创 Leetcode:203. Remove Linked List Elements(Java)
【问题描述】Remove all elements from a linked list of integers that have value val.ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 --> 2 --> 3 --> 4 --> 5Credits:Sp
2016-03-15 20:30:28
340
原创 Leetcode:290. Word Pattern(JAVA)
【问题描述】Given a pattern and a string str, find if str follows the same pattern.Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty wo
2016-03-15 20:14:32
336
原创 Leetcode:38. Count and Say(JAVA)
【问题描述】The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1 is read off as "one 1" or 11.11 is read off as "two 1s" or 21.21 is
2016-03-15 19:49:57
297
原创 Leetcode:205. Isomorphic Strings(JAVA)
【问题描述】Given two strings s and t, determine if they are isomorphic.Two strings are isomorphic if the characters in s can be replaced to get t.All occurrences of a character must be replac
2016-03-15 17:24:51
335
原创 Leetcode:299. Bulls and Cows(JAVA)
【问题描述】You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time your friend makes a guess, you prov
2016-03-14 16:25:11
343
原创 Leetcode:20. Valid Parentheses(JAVA)
【问题描述】Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}"
2016-03-14 15:46:13
479
原创 Leetcode:19. Remove Nth Node From End of List(JAVA)
【问题描述】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
2016-03-14 15:30:06
266
原创 Leetcode:58. Length of Last Word(JAVA)
【问题描述】Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, return 0.Not
2016-03-13 11:58:39
435
原创 Leetcode: 7. Reverse Integer(JAVA)
【问题描述】Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321click to show spoilers.【思路】此题看似简单,但是坑较多。整数反转问题较简单,但是需要处理溢出问题。将结果保存为long型,如果大于整数
2016-03-13 11:49:18
550
原创 Leetcode: 190. Reverse Bits(JAVA)
【问题描述】Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary
2016-03-13 11:18:49
1015
原创 Leetcode:223. Rectangle Area(JAVA)
【问题描述】Find the total area covered by two rectilinear rectangles in a 2D plane.Each rectangle is defined by its bottom left corner and top right corner as shown in the figure.Assume t
2016-03-13 11:04:11
365
原创 Leetcode:219. Contains Duplicate II(JAVA)
【问题描述】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 difference between i and jis at mo
2016-03-13 10:26:00
321
原创 Leetcode:88. Merge Sorted Array(JAVA)
【问题描述】Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:You may assume that nums1 has enough space (size that is greater or equal to m + n) t
2016-03-13 09:49:08
1757
原创 Leetcode:36. Valid Sudoku(JAVA)
【问题描述】Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character '.'.A p
2016-03-12 21:33:13
369
原创 Leetcode:160. Intersection of Two Linked Lists(JAVA)
【问题描述】Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a1 → a2 ↘
2016-03-12 17:05:42
316
原创 Leetcode:111. Minimum Depth of Binary Tree(JAVA)
【问题描述】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.Subscribe to s
2016-03-10 11:37:33
312
原创 Leetcode:225. Implement Stack using Queues(JAVA)
【问题描述】Implement the following operations of a stack using queues.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top() -- Get the top element.empty() --
2016-03-10 10:45:36
409
原创 Leetcode: 112. Path Sum(JAVA)
【问题描述】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 path equals the given sum.For example:Given the below binary t
2016-03-10 10:32:10
224
原创 Leetcode: 107. Binary Tree Level Order Traversal II(JAVA)
【问题描述】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
2016-03-09 20:12:28
351
原创 Leetcode:9. Palindrome Number(JAVA)
【问题描述】Determine whether an integer is a palindrome. Do this without extra space.【思路】在O(1)的空间复杂度内,因此不能转化为字符串反转字符串。循环除以10取出最左端数字,mod10取最右端数字,依次进行比较。public class Solution { public boole
2016-03-08 12:25:21
321
原创 Leetcode:172. Factorial Trailing Zeroes(JAVA)
【问题描述】Given an integer n, return the number of trailing zeroes in n!.Note: Your solution should be in logarithmic time complexity.【思路】关于N的阶乘后面有几个0,即Factorial Trailing Zeroes。分解因子,当且出现一
2016-03-08 11:14:06
529
原创 Leetcode:102. Binary Tree Level Order Traversal(JAVA)
【问题描述】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 / \
2016-03-08 10:58:44
232
原创 Leetcode:119. Pascal's Triangle II(JAVA)
【问题描述】Given an index k, return the kth row of the Pascal's triangle.For example, given k = 3,Return [1,3,3,1].【思路】递归实现public class Solution { public List getRow(int rowIndex) {
2016-03-08 10:38:15
268
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人