![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
java
文章平均质量分 66
不智鱼
这个作者很懒,什么都没留下…
展开
-
[LeetCode] String to Integer (atoi)
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 possible input ca原创 2014-09-03 17:44:41 · 413 阅读 · 0 评论 -
[LeetCode] Decode Ways
A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message containing digits, determine the total nu原创 2014-08-27 15:50:12 · 297 阅读 · 0 评论 -
[LeetCode] Restore IP Addresses
Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given "25525511135",return ["255.255.11.135", "255.255.111.35"]. (Order原创 2014-08-27 15:17:34 · 313 阅读 · 0 评论 -
[LeetCode] Minimum Window Substring
Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S = "ADOBECODEBANC"T = "ABC"Minimum window is "BANC"原创 2014-08-27 14:33:41 · 340 阅读 · 0 评论 -
[LeetCode] Longest Palindromic Substring
Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring.原创 2014-08-27 10:54:02 · 351 阅读 · 0 评论 -
[LeetCode] Reverse Linked List II
Reverse a linked list from position m to n. Do it in-place and in one-pass.For example:Given 1->2->3->4->5->NULL, m = 2 and n = 4,return 1->4->3->2->5->NULL.Note:Given m, n satisfy the原创 2014-08-27 00:06:41 · 307 阅读 · 0 评论 -
对象的序列化与Serializable 接口
对象的序列化与Serializable 接口1. 基本的序列化操作 一般来说,对象只存在与进程运行期间,进程中止后,你所创建的对象就灰飞烟灭。但是有的时候,你需要在程序中止后继续保留对象信息,这样下次运行时,你可以将对象重建恢复到程序上次运行时它所拥有的信息。 Java中提供了Serializable接口来标记可序列化的对象。public interface Ser原创 2014-08-24 19:52:27 · 470 阅读 · 0 评论 -
[LeetCode] Validate Binary Search Tree
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.原创 2014-08-23 15:33:11 · 333 阅读 · 0 评论 -
[LeetCode] Recover Binary Search Tree
原题地址:https://oj.leetcode.com/problems/recover-binary-search-tree/Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:原创 2014-08-23 14:59:00 · 452 阅读 · 0 评论 -
[LeetCode] Maximal Rectangle
Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.将二维的问题转换为一维问题原创 2014-08-27 17:16:30 · 353 阅读 · 0 评论 -
[LeetCode] Median of Two Sorted Arrays
There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).原创 2014-09-02 21:11:03 · 380 阅读 · 0 评论 -
[LeetCode] Insertion Sort List
Insertion Sort List Total Accepted: 18506 Total Submissions: 73505 My SubmissionsSort a linked list using insertion sort.链表的插入排序,没什么原创 2014-08-18 15:25:18 · 279 阅读 · 0 评论 -
[LeetCode] Sort List
Sort a linked list in O(n log n) time using constant space complexity.public class SortList { static class ListNode { int val; ListNode next; ListNode(int x) { val =原创 2014-08-15 17:06:48 · 286 阅读 · 0 评论 -
[LeetCode] Max Points on a Line
Max Points on a Line Total Accepted: 16037 Total Submissions: 148156 My SubmissionsGiven n points on a 2D plane, find the maximum number of points that lie on the same straight line.原创 2014-08-15 14:56:34 · 288 阅读 · 0 评论 -
[LeetCode] Simplify Path
Given an absolute path for a file (Unix-style), simplify it.For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c"public class Solution { public String simplifyPath原创 2014-08-28 15:23:07 · 306 阅读 · 0 评论 -
[LeetCode] Add Binary
Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".原创 2014-08-28 14:39:00 · 335 阅读 · 0 评论 -
[LeetCode] Largest Rectangle in Histogram
Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.Above is a histogram where width o原创 2014-08-27 16:55:37 · 297 阅读 · 0 评论 -
[LeetCode] Evaluate Reverse Polish Notation
Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or another expression.Some examples:["2", "1", "+", "原创 2014-08-14 19:42:28 · 264 阅读 · 0 评论 -
[LeetCode] Interleaving String
Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.For example,Given:s1 = "aabcc",s2 = "dbbca",When s3 = "aadbbcbcac", return true.When s3 = "aadbbbaccc", r原创 2014-08-23 17:34:07 · 334 阅读 · 0 评论 -
[LeetCode] Construct Binary Tree from Inorder and Postorder Traversal
原题地址:https://oj.leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal/Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume原创 2014-08-22 20:57:16 · 408 阅读 · 0 评论 -
[LeetCode] Longest Substring Without Repeating Characters
原题地址:https://oj.leetcode.com/problems/longest-substring-without-repeating-characters/Given a string, find the length of the longest substring without repeating characters. For example, the longe原创 2014-08-22 10:51:56 · 296 阅读 · 0 评论 -
[LeetCode] Next Permutation
Next Permutation Total Accepted: 14635 Total Submissions: 57694 My SubmissionsImplement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.原创 2014-09-04 20:23:30 · 374 阅读 · 0 评论 -
[LeetCode] Clone Graph
Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.OJ's undirected graph serialization:Nodes are labeled uniquely.We use # as a separator for ea原创 2014-08-20 21:27:32 · 417 阅读 · 0 评论 -
[面试题] 求周长最长的三角形
题目:给定一组长短不一的棍子,求能组成的周长最长的三角形。分析:原创 2014-08-20 15:07:14 · 1385 阅读 · 0 评论 -
[LeetCode] Gas Station
There are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to it原创 2014-08-19 20:39:11 · 417 阅读 · 0 评论 -
[LeetCode] Candy
There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child must have at least on原创 2014-08-19 20:08:39 · 263 阅读 · 0 评论 -
[LeetCode] Copy List with Random Pointer
A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy of the list.原创 2014-08-19 16:14:54 · 277 阅读 · 0 评论 -
[LeetCode] LRU Cache
Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set.get(key) - Get the value (will always be positive) of the key if原创 2014-08-18 20:27:43 · 313 阅读 · 0 评论 -
[LeetCode] Merge k Sorted Lists
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.递归原创 2014-09-04 20:46:26 · 317 阅读 · 0 评论 -
[面试题] 递增序列生成
思路:和《剑指OFFER》中求丑数的题目很像,序列中第N个数 必然是是前N - 1个数乘以 2 或者乘以5 中大于第N - 1个数的最小值。可以通过分别标记上次乘以2 或乘以5的位置开始寻找被乘数。取最小值,如果 乘以2 的小 则第N个数为该数,同时将2的标记位置右移一位,同理乘以5小时右移5的标记位置,二者相同时同时右移两位。显然,肯定能保证所得数比上一个数大。原创 2014-08-20 13:55:15 · 733 阅读 · 0 评论 -
[LeetCode] Maximum Subarray
Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [−2,1,−3,4,−1,2,1,−5,4],the contiguous subarray [4,−1,2,1] ha原创 2014-08-22 11:22:21 · 273 阅读 · 0 评论 -
[LeetCode] Longest Consecutive Sequence
原题链接: https://oj.leetcode.com/problems/longest-consecutive-sequence/Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given原创 2014-08-22 09:47:25 · 430 阅读 · 0 评论 -
[LeetCode] Distinct Subsequences
Given a string S and a string T, count the number of distinct subsequences of T in S.A subsequence of a string is a new string which is formed from the original string by deleting some (can be non原创 2014-08-22 20:12:41 · 299 阅读 · 0 评论 -
[LeetCode] Surrounded Regions
Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'.A region is captured by flipping all 'O's into 'X's in that surrounded region.For example,X X X XX O O X原创 2014-08-21 12:57:35 · 310 阅读 · 0 评论 -
二叉树的先序、中序、后序、层次遍历的递归和非递归解法
二叉树的先序、中序、后序、层次遍历的递归和非递归解法package tree;import java.util.LinkedList;import java.util.Queue;import java.util.Stack;public class TreeTraverse { /** * 先序递归 * @param root */ public stat原创 2014-09-05 15:30:25 · 847 阅读 · 0 评论 -
[LeetCode] Word Ladder
原题地址:https://oj.leetcode.com/problems/word-ladder/原创 2014-08-21 12:47:12 · 373 阅读 · 0 评论 -
[LeetCode] Palindrome Partitioning II
原题地址:https://oj.leetcode.com/problems/palindrome-partitioning-ii/Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palin原创 2014-08-21 10:02:58 · 525 阅读 · 0 评论 -
[LeetCode] Word Break II
题目链接:https://oj.leetcode.com/problems/word-break-ii/Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word.Return all原创 2014-08-21 09:51:57 · 602 阅读 · 0 评论 -
ArrayList 和 Vector 比较
JAVA中ArrayList 和 Vector 比较: 1. API 从提供API来看,二者几乎一致,vector多了element系列API,如elementAt()、firstElement()等。但实现的功能基本一致,故如果需要选择的时候API的差别不应该一个重要的参考项 2. 线程同步 Vector的每个方法都是线程同步的,因此当需要原创 2014-03-26 11:19:56 · 425 阅读 · 0 评论