leetcode
文章平均质量分 68
蓝色彼岸W
越努力越幸运
展开
-
leetcode第三题Longest Substring Without Repeating Characters java
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. Fo原创 2015-03-10 14:18:08 · 676 阅读 · 0 评论 -
lettcode-102:Binary Tree Level Order Traversal (Java)
Binary Tree Level Order Traversal二叉树的层序遍历两种方式:1、用两个queue交替表示每一层的节点2、用两个node,一个表示当前层的最后一个节点,一个表示下一层的最后一个节点/** * Definition for a binary tree node. * public class TreeNode { * int val;原创 2015-08-18 19:53:03 · 569 阅读 · 0 评论 -
leetcode-110:判断平衡二叉树 Java
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 subtre原创 2015-08-17 22:04:52 · 1138 阅读 · 0 评论 -
leetcode-173:Binary Search Tree Iterator(Java)
Binary Search Tree IteratorImplement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Calling next() will return the next smallest n原创 2015-08-18 10:58:59 · 2664 阅读 · 0 评论 -
leetcode-94:Binary Tree Inorder Traversal (Java)
Binary Tree Inorder Traversal 即二叉树的中序遍历。常见的有两种方法:递归和循环,其中递归调用的栈空间为树的高度,一般为o(logn),循环方式需要开辟一个栈来保存元素,空间复杂度也是o(logn)tips: 递归比循环耗时,递归:400ms,循环:220ms另外还以一种方式遍历二叉树:Morr原创 2015-08-18 15:03:00 · 1267 阅读 · 0 评论 -
leetcode第七题Reverse Integer (java)
Reverse IntegerReverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321time=272ms acceptedpublic class Solution { public int reverse(int x) {原创 2015-03-17 14:17:12 · 419 阅读 · 0 评论 -
leetcode第八题 String to Integer (atoi) (java)
String to Integer (atoi)time=272ms accepted 需考虑各种可能出现的情况public class Solution { public int atoi(String str) { int length=str.length(); long result=0原创 2015-03-26 10:50:32 · 433 阅读 · 0 评论 -
leetcode 第二题Add Two Numbers java
/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { * val = x; * next = null; * } * } */public原创 2015-03-09 11:33:12 · 1154 阅读 · 1 评论 -
leetcode第六题 ZigZag Conversion (java)
ZigZag ConversionThe 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原创 2015-03-13 09:08:08 · 470 阅读 · 0 评论 -
leetcode 第五题 Longest Palindromic Substring (java)
Longest Palindromic SubstringGiven 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 palindrom原创 2015-03-12 14:25:37 · 499 阅读 · 0 评论 -
leetcode 第九题 Palindrome Number(java)
Palindrome Numbertime=434ms负数不是回文数public class Solution { public boolean isPalindrome(int x) { int palindrome=0; int revers=x; if(revers<0) return f原创 2015-03-26 11:16:44 · 412 阅读 · 0 评论 -
leetcode第四题:Median of Two Sorted Arrays (java)
Median of Two Sorted ArraysThere 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)).ti原创 2015-03-11 14:35:19 · 584 阅读 · 0 评论 -
leetcode 第一题 Two Num java
public class Solution { public int[] twoSum(int[] numbers, int target) { int length=numbers.length; int[] sortNum=new int[length]; sortNum=quickSort(numbers,0,length-1);原创 2015-03-08 11:08:45 · 762 阅读 · 0 评论 -
leetcode-124:Binary Tree Maximum Path Sum(Java)
Binary Tree Maximum Path SumGiven a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the below binary tree,原创 2015-08-21 20:25:21 · 638 阅读 · 0 评论