![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode
zhangxzhi
这个作者很懒,什么都没留下…
展开
-
[leetcode] CompareVersionNumbers
package temworkingarea;import leetcode.tag.JavaEye;@JavaEye/** * * Compare two version numbers version1 and version1. * If version1 > version2 return 1, if version1 < version2 return ...2015-01-10 10:05:38 · 276 阅读 · 0 评论 -
[leetcode] PowXN
package leetcode;/** * * Implement pow(x, n). * */public class PowXN { public static class Solution2 { public double pow(double x, int n) { if (n < 0) { ...2014-10-25 00:07:49 · 125 阅读 · 0 评论 -
[leetcode] PathSum
package leetcode;/** * * 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 exam...2014-10-25 00:08:49 · 78 阅读 · 0 评论 -
[leetcode] GasStation
/** * * 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 f...2014-10-26 00:43:12 · 80 阅读 · 0 评论 -
[leetcode] ReverseWordsinaString
package leetcode;import java.util.Stack;/** * * Given an input string, reverse the string word by word. * * For example, * Given s = "the sky is blue", * return "blue is sky the"...2014-10-26 00:45:03 · 111 阅读 · 0 评论 -
[leetcode] ValidateBinarySearchTree
package t;import java.util.ArrayList;import java.util.List;/** * * Given a binary tree, determine if it is a valid binary search tree (BST). * * Assume a BST is defined as follows:...2014-10-29 12:24:02 · 90 阅读 · 0 评论 -
[leetcode] SymmetricTree
package t;/** * * Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). * * For example, this binary tree is symmetric: * * 1 * / \...2014-10-29 12:59:27 · 77 阅读 · 0 评论 -
[leetcode] MinimumDepthofBinaryTree
package leetcode;/** * * * 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 lea...2014-11-05 17:05:59 · 101 阅读 · 0 评论 -
[leetcode] SqrtX
package leetcode;/** * * Implement int sqrt(int x). * * Compute and return the square root of x. * * */public class SqrtX { public static class Solution { public int...2014-11-05 17:08:05 · 110 阅读 · 0 评论 -
[leetcode] SearchforaRange
public int[] searchRange(int[] A, int target) { if (A == null || A.length == 0) { return new int[] { -1, -1 }; } int start = start(A, ...2014-11-11 19:45:30 · 198 阅读 · 0 评论 -
[leetcode] SingleNumber2
public class Solution { public int singleNumber(int[] A) { int[] tem = new int[32]; for (int a : A) { int x = 1; for (int t = 0...2014-11-11 20:57:46 · 112 阅读 · 0 评论 -
[leetcode] PascalsTriangle2
/** * * Given an index k, return the kth row of the Pascal's triangle. * * For example, given k = 3, * Return [1,3,3,1]. * * Note: * Could you optimize your algorithm to use only O(...2014-11-19 17:33:03 · 148 阅读 · 0 评论 -
[leetcode] PalindromeNumber
/** * Determine whether an integer is a palindrome. Do this without extra space. * */public class PalindromeNumber { public class Solution { public boolean isPalindrome(int x) { ...2014-12-16 00:18:12 · 106 阅读 · 0 评论 -
[leetcode] PopulatingNextRightPointersinEachNode
package leetcode;import leetcode.tag.NeedStudyMore;@NeedStudyMore/** * * Given a binary tree * * struct TreeLinkNode { * TreeLinkNode *left; * TreeLinkNode *right; * Tr...2014-10-25 00:03:37 · 128 阅读 · 0 评论 -
[leetcode] RemoveDuplicatesfromSortedList
package leetcode;/** * * Given a sorted linked list, delete all duplicates such that each element appear only once. * * For example, * Given 1->1->2, return 1->2. * Given 1->1->2->3-...2014-10-25 00:02:18 · 86 阅读 · 0 评论 -
[leetcode] ValidParentheses
package leetcode;import java.util.Stack;/** * * Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. * * The bracket...2014-10-24 23:24:05 · 86 阅读 · 0 评论 -
[leetcode] DungeonGame
package temworkingarea;/** * * The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a 2D grid. ...2015-02-25 17:45:10 · 238 阅读 · 0 评论 -
[leetcode] AddTwoNumbers
/** * * * You are given two linked lists representing two non-negative numbers. * The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers ...2014-10-19 11:38:13 · 72 阅读 · 0 评论 -
[leetcode] BinaryTreePreorderTraversal
package leetcode;import java.util.ArrayList;import java.util.List;import java.util.Stack;/** * * Given a binary tree, return the preorder traversal of its nodes' values. * * Fo...2014-10-19 11:41:59 · 89 阅读 · 0 评论 -
[leetcode] ClimbingStairs
/** * * You are climbing a stair case. It takes n steps to reach to the top. * * Each time you can either climb 1 or 2 steps. * In how many distinct ways can you climb to the top? * ...2014-10-19 12:00:52 · 74 阅读 · 0 评论 -
[leetcode] FindMinimuminRotatedSortedArray
package leetcode;/** * Find Minimum in Rotated Sorted Array * * * Suppose a sorted array is rotated at some pivot unknown to you * beforehand. * * (i.e., 0 1 2 4 5 6 7 might become ...2014-10-19 14:39:55 · 108 阅读 · 0 评论 -
[leetcode] LinkedListCycle
package leetcode;/** * * Given a linked list, determine if it has a cycle in it. * * Follow up: * Can you solve it without using extra space? * * */public class LinkedListCycle ...2014-10-19 14:41:04 · 87 阅读 · 0 评论 -
[leetcode] SumRoottoLeafNumbers
package leetcode;/** * * Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. * * An example is the root-to-leaf path 1->2->3 which repre...2014-10-21 23:21:39 · 85 阅读 · 0 评论 -
[leetcode] BestTimetoBuyandSellStock
package leetcode;/** * * Say you have an array for which the ith element is the price of a given stock on day i. * * If you were only permitted to complete at most one transaction (ie, b...2014-10-21 23:24:37 · 79 阅读 · 0 评论 -
[leetcode] FindMinimuminRotatedSortedArray2
/** * * * Follow up for "Find Minimum in Rotated Sorted Array": * What if duplicates are allowed? * * Would this affect the run-time complexity? How and why? * Suppose a sorted array ...2014-10-22 00:31:25 · 99 阅读 · 0 评论 -
[leetcode] MaximumDepthofBinaryTree
/** * * Given a binary tree, find its maximum depth. * * The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. * * */publi...2014-10-22 00:56:37 · 84 阅读 · 0 评论 -
[leetcode] MergeSortedArray
package leetcode;/** * * Given two sorted integer arrays A and B, merge B into A as one sorted array. * * Note: * You may assume that A has enough space (size that is greater or equal ...2014-10-23 23:15:19 · 88 阅读 · 0 评论 -
[leetcode] MinimumPathSum
package leetcode;/** * * Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path. * * Note: Y...2014-10-23 23:16:23 · 80 阅读 · 0 评论 -
[leetcode] SameTree
/** * * Given two binary trees, write a function to check if they are equal or not. * * Two binary trees are considered equal if they are structurally identical and the nodes have the same v...2014-12-16 00:20:28 · 111 阅读 · 0 评论