10 2017 档案

摘要:Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 思路:既然数组里的元素已经按升序排好序了,那么不难想到用二分法来做这道题。 /** * Definiti 阅读全文
posted @ 2017-10-29 13:25 SkyMelody 阅读(111) 评论(0) 推荐(0) 编辑
摘要:Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) Yo 阅读全文
posted @ 2017-10-29 11:25 SkyMelody 阅读(150) 评论(0) 推荐(0) 编辑
摘要:Given an unsorted array of integers, find the length of longest continuous increasing subsequence. Example 1: Example 2: Note: Length of the array wil 阅读全文
posted @ 2017-10-27 16:04 SkyMelody 阅读(99) 评论(0) 推荐(0) 编辑
摘要:Given a binary array, find the maximum number of consecutive 1s in this array. Example 1: Note: The input array will only contain 0 and 1. The length 阅读全文
posted @ 2017-10-27 13:09 SkyMelody 阅读(95) 评论(0) 推荐(0) 编辑
摘要:Given a non-negative integer represented as a non-empty array of digits, plus one to the integer. You may assume the integer do not contain any leadin 阅读全文
posted @ 2017-10-27 09:56 SkyMelody 阅读(83) 评论(0) 推荐(0) 编辑
摘要:Given an integer array, find three numbers whose product is maximum and output the maximum product. Example 1: Input: [1,2,3] Output: 6 Example 2: Inp 阅读全文
posted @ 2017-10-26 22:55 SkyMelody 阅读(112) 评论(0) 推荐(0) 编辑
摘要:Given a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time complexi 阅读全文
posted @ 2017-10-26 16:35 SkyMelody 阅读(83) 评论(0) 推荐(0) 编辑
摘要:Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements. For example, giv 阅读全文
posted @ 2017-10-26 13:23 SkyMelody 阅读(80) 评论(0) 推荐(0) 编辑
摘要:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in or 阅读全文
posted @ 2017-10-26 12:46 SkyMelody 阅读(77) 评论(0) 推荐(0) 编辑
摘要:Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), ..., (an, bn) which makes sum of 阅读全文
posted @ 2017-10-26 07:52 SkyMelody 阅读(85) 评论(0) 推荐(0) 编辑
摘要:Given an array and a value, remove all instances of that value in place and return the new length. Do not allocate extra space for another array, you 阅读全文
posted @ 2017-10-25 22:34 SkyMelody 阅读(121) 评论(0) 推荐(0) 编辑
摘要: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 tha 阅读全文
posted @ 2017-10-25 22:09 SkyMelody 阅读(93) 评论(0) 推荐(0) 编辑
摘要: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 fo 阅读全文
posted @ 2017-10-24 21:06 SkyMelody 阅读(92) 评论(0) 推荐(0) 编辑
摘要:Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array. For example,Given nums = [0, 1, 阅读全文
posted @ 2017-10-24 20:08 SkyMelody 阅读(101) 评论(0) 推荐(0) 编辑
摘要:Given an array of integers and an integer k, you need to find the number of unique k-diff pairs in the array. Here a k-diff pair is defined as an inte 阅读全文
posted @ 2017-10-24 12:50 SkyMelody 阅读(145) 评论(0) 推荐(0) 编辑
摘要: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 dept 阅读全文
posted @ 2017-10-23 13:38 SkyMelody 阅读(95) 评论(0) 推荐(0) 编辑
摘要: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 l 阅读全文
posted @ 2017-10-22 13:42 SkyMelody 阅读(96) 评论(0) 推荐(0) 编辑
摘要: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 l 阅读全文
posted @ 2017-10-22 13:13 SkyMelody 阅读(120) 评论(0) 推荐(0) 编辑
摘要:Invert a binary tree. to 1 /** 2 * Definition for a binary tree node. 3 * public class TreeNode { 4 * int val; 5 * TreeNode left; 6 * TreeNode right; 阅读全文
posted @ 2017-10-22 11:25 SkyMelody 阅读(127) 评论(0) 推荐(0) 编辑
摘要:Given a binary search tree and the lowest and highest boundaries as L and R, trim the tree so that all its elements lies in [L, R] (R >= L). You might 阅读全文
posted @ 2017-10-21 15:54 SkyMelody 阅读(184) 评论(0) 推荐(0) 编辑
摘要:Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all 阅读全文
posted @ 2017-10-20 16:32 SkyMelody 阅读(129) 评论(0) 推荐(0) 编辑
摘要: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 a 阅读全文
posted @ 2017-10-19 15:07 SkyMelody 阅读(111) 评论(0) 推荐(0) 编辑
摘要: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. F 阅读全文
posted @ 2017-10-19 06:59 SkyMelody 阅读(84) 评论(0) 推荐(0) 编辑
摘要:Write a function to delete a node (except the tail) in a singly linked list, given only access to that node. Supposed the linked list is 1 -> 2 -> 3 - 阅读全文
posted @ 2017-10-12 07:27 SkyMelody 阅读(114) 评论(0) 推荐(0) 编辑