![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode
文章平均质量分 55
冰凌花花
欢迎来到我的博客, 本人乃互联网行业一枚小小的螺丝钉—非典型程序员妹子.
展开
-
Reverse Integer LeetCode Java
Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321public class Solution { public int reverse(int x) { if(x==Integer.MIN_VALUE)原创 2016-10-26 22:19:40 · 293 阅读 · 0 评论 -
Binary Tree Inorder Traversal leetcode
Given a binary tree, return the inorder traversal of its nodes' values.For example:Given binary tree [1,null,2,3], 1 \ 2 / 3return [1,3,2].非递归的方法写二叉树的中序遍历。原创 2016-08-13 18:15:01 · 215 阅读 · 0 评论 -
Binary Tree Preorder Traversal leetcode
Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,2,3].二叉树的前序遍历,非递归的写法考的比较多,方法很原创 2016-08-12 19:15:54 · 231 阅读 · 0 评论 -
Find Peak Element leetcode
Hi 大家,这道题是leetcode上的find peak element的题,不是lintcode的那道,这两道题是有区别的,lintcode的题目中说明了:只有某个数左右两侧的元素都小于它,这个数才是峰值,而leetcode的题,是只要找到个最大值就行,可以是[1,2]里的2这种。A peak element is an element that原创 2016-08-11 12:35:15 · 209 阅读 · 0 评论 -
Same Tree Leetcode
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 value.给出两个二叉树,写一原创 2016-08-18 13:13:02 · 186 阅读 · 0 评论 -
Word Break leetcode
Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.For example, givens = "leetcode",dict = ["leet"原创 2016-08-22 16:19:05 · 213 阅读 · 0 评论 -
leetcode 278. First Bad Version
The code base version is an integer start from 1 to n. One day, someone committed a bad version in the code case, so it caused this version and the following versions are all failed in the unit tests.原创 2016-08-09 23:25:01 · 204 阅读 · 0 评论 -
leetcode 34. Search for a Range
Given a sorted array of n integers, find the starting and ending position of a given target value.If the target is not found in the array, return [-1, -1].ExampleGiven [5, 7, 7, 8, 8, 10] an原创 2016-08-10 23:45:46 · 143 阅读 · 0 评论 -
Flatten Binary Tree to Linked List leetcode
Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened tree should look like: 1原创 2016-08-18 15:11:12 · 171 阅读 · 0 评论 -
Unique Paths II leetcode
Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space is marked as 1 and 0 respectively in the原创 2016-08-18 16:22:09 · 267 阅读 · 0 评论 -
Minimum Path Sum 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: You can only move either down or right at原创 2016-08-18 16:46:37 · 230 阅读 · 0 评论 -
Triangle leetcode
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], [3,4], [原创 2016-08-18 20:00:20 · 209 阅读 · 0 评论 -
Jump Game leetcode
Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determine i原创 2016-08-20 15:35:32 · 503 阅读 · 0 评论 -
Edit Distance leetcode java
Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have the following 3 operations permitted on a word:原创 2016-08-21 17:27:30 · 361 阅读 · 0 评论 -
Maximum Depth of Binary Tree leetcode
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.求一个二叉树的最大长度。/** * Definition原创 2016-08-13 18:43:23 · 233 阅读 · 0 评论 -
Balanced Binary Tree leetcode
Given 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 subtrees of every node never diffe原创 2016-08-14 16:06:02 · 184 阅读 · 0 评论 -
Add Two Numbers LeetCode Java
Add Two Numbers原创 2016-10-26 20:17:25 · 244 阅读 · 0 评论 -
Two Sum Leetcode
Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution.Example:Given nums =原创 2016-10-26 18:29:22 · 335 阅读 · 0 评论 -
Merge k Sorted Lists Leetcode Java
Merge k Sorted Lists原创 2016-09-08 14:34:05 · 299 阅读 · 0 评论 -
Interleaving String leetcode
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", ret原创 2016-08-24 14:53:15 · 181 阅读 · 0 评论 -
Longest Common Substring
Given two strings, find the longest common substring.Return the length of it.ExampleGiven A = "ABCD", B = "CBCE", return 2.public class Solution { /** * @param A, B: Two原创 2016-08-24 11:13:12 · 253 阅读 · 0 评论 -
Distinct Subsequences Leetcode
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原创 2016-08-23 15:53:58 · 311 阅读 · 0 评论 -
lintcode 75 Find Peak Element
There is an integer array which has the following features:The numbers in adjacent positions are different.A[0] A[A.length - 1].We define a position P is a peek if:A[P] > A[P-1] && A[P] > A原创 2016-08-10 18:55:51 · 540 阅读 · 0 评论 -
Longest Common Subsequence
Given two strings, find the longest common subsequence (LCS).Your code should return the length of LCS.ClarificationWhat's the definition of Longest Common Subsequence?https://en.wikiped原创 2016-08-23 14:06:55 · 391 阅读 · 0 评论 -
Palindrome Partitioning II Leetcode
Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning of s.For example, given s = "aab",Return原创 2016-08-23 11:33:27 · 251 阅读 · 0 评论 -
Binary Tree Level Order Traversal leetcode
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,null,null,15,7], 3 / \ 9 2原创 2016-08-17 14:04:24 · 199 阅读 · 0 评论 -
Validate Binary Search Tree leetcode
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.Th原创 2016-08-17 10:56:06 · 253 阅读 · 0 评论 -
Binary Tree Maximum Path Sum leetcode
Given a binary tree, find the maximum path sum.For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connections. The原创 2016-08-16 14:55:19 · 183 阅读 · 0 评论 -
Lowest Common Ancestor of a Binary Tree leetcode
Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes原创 2016-08-14 23:18:02 · 220 阅读 · 0 评论 -
lintcode 447 Search in a Big Sorted Array
Given a big sorted array with positive integers sorted by ascending order. The array is so big so that you can not get the length of the whole array directly, and you can only access the kth number by原创 2016-08-09 22:31:35 · 802 阅读 · 0 评论 -
Two Strings Are Anagrams
Two Strings Are Anagrams原创 2016-09-09 18:04:21 · 505 阅读 · 0 评论 -
leetcode 83. Remove Duplicates from Sorted List
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->3, return 1->2->3. /** * Definition f原创 2016-07-25 19:37:22 · 161 阅读 · 0 评论 -
leetcode 82. Remove Duplicates from Sorted List II
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example,Given 1->2->3->3->4->4->5, return 1->2->5.Given 1->1-原创 2016-07-28 14:56:52 · 162 阅读 · 0 评论 -
leetcode 86. Partition List
Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve the original relative order of the nodes in each of原创 2016-07-28 13:07:05 · 269 阅读 · 0 评论 -
leetcode 62. Unique Paths
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the原创 2016-07-27 10:06:33 · 212 阅读 · 0 评论 -
leetcode 345. Reverse Vowels of a String
Write a function that takes a string as input and reverse only the vowels of a string.Example 1:Given s = "hello", return "holle".Example 2:Given s = "leetcode", return "leotcede".Note原创 2016-07-26 14:47:14 · 201 阅读 · 0 评论 -
leetcode 344. Reverse String
Write a function that takes a string as input and returns the string reversed.Example:Given s = "hello", return "olleh".第一次使用的是string来做,从后往前遍历输入的string,依次存入新的string中,提交的时候没有通过,因为超时了。超时的方法如下:原创 2016-07-26 11:55:49 · 214 阅读 · 0 评论 -
leetcode 88. Merge Sorted Array
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) to hold addit原创 2016-07-25 20:30:56 · 165 阅读 · 0 评论 -
leetcode 7. Reverse Integer
Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321click to show spoilers.Have you thought about this?Here are some good questions to ask before c原创 2016-07-24 22:50:22 · 193 阅读 · 0 评论 -
leetcode 26. Remove Duplicates from Sorted Array
Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this in place with原创 2016-07-22 17:36:39 · 163 阅读 · 0 评论