![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode
SYSU_ZYH
这个作者很懒,什么都没留下…
展开
-
Kth Largest Element in an Array——Difficulty:Medium
Problem :Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.Example:Given [3,2,1,5,6,4] and k = 2, return 5.Not原创 2016-09-11 17:49:38 · 309 阅读 · 0 评论 -
Arithmetic Slices——Difficulty:Memium
Problem :A sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.Example:For example, these are arithm原创 2016-10-17 19:00:56 · 297 阅读 · 0 评论 -
Split Array Largest Sum——Difficulty:Hard
Problem :Given an array which consists of non-negative integers and an integer m, you can split the array into m non-empty continuous subarrays. Write an algorithm to minimize the largest sum among the原创 2016-10-17 20:51:21 · 352 阅读 · 2 评论 -
Count Numbers with Unique Digits——Difficulty:Medium
Problem :Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n.Example:Given n = 2, return 91. (The answer should be the total numbers in the range of 0 ≤ x < 100,原创 2016-11-14 15:22:08 · 263 阅读 · 0 评论 -
Integer Break——Difficulty:Medium
Problem :Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get.Example:For example, give原创 2016-11-14 15:54:06 · 242 阅读 · 0 评论 -
Burst Balloons——Difficulty:Hard
Problem :Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by array nums. You are asked to burst all the balloons. If the you burst balloon i you will get原创 2016-12-19 14:51:04 · 225 阅读 · 0 评论 -
Maximum Subarray——Difficulty:Medium
Problem :Find the contiguous subarray within an array (containing at least one number) which has the largest sum.Example:For example, given the array [-2,1,-3,4,-1,2,1,-5,4],the contiguous subarray [4原创 2016-12-19 15:38:43 · 215 阅读 · 0 评论 -
Different Ways to Add Parentheses——Difficulty:Medium
Problem :Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. The valid operators are +, - and *.Example:E原创 2017-01-07 15:09:30 · 253 阅读 · 0 评论 -
House Robber III——Difficulty:Medium
Problem :The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the “root.” Besides the root, each house has one and only one parent house. Afte原创 2016-12-20 14:15:53 · 271 阅读 · 0 评论 -
Maximum Depth of Binary Tree——Difficulty:Easy
Problem :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.Example:**Algorithm:** 水题水一下。。。**原创 2016-12-20 14:20:18 · 251 阅读 · 0 评论 -
Symmetric Tree(递归和非递归方法) ——Difficulty:Easy
Problem :Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).Example:For example, this binary tree [1,2,2,3,4,4,3] is symmetric: 1 / \ 2 2 / \ / \3原创 2016-10-10 22:24:22 · 295 阅读 · 0 评论 -
Binary Tree Zigzag Level Order Traversal——Difficulty:Medium
Problem :Given a binary tree, return the zigzag level order traversal of its nodes’ values. (ie, from left to right, then right to left for the next level and alternate between).Example:For example:Gi原创 2016-10-10 20:51:26 · 222 阅读 · 0 评论 -
Merge k Sorted Lists——Difficulty:Hard
Problem :Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.Example:**Algorithm:** 通过两个list的归并在推出多个lists的归并,两个list归并是下列代码的mergeTwoLists()函数。做法是: 取任原创 2016-09-11 19:30:21 · 279 阅读 · 1 评论 -
Majority Element——Difficulty:Easy
Problem :Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the majority elemen原创 2016-09-12 16:07:34 · 235 阅读 · 0 评论 -
Find the difference——Difficulty:Easy
Problem :Given two strings s and t which consist of only lowercase letters. String t is generated by random shuffling string s and then add one more letter at a random position. Find the letter that w原创 2016-09-04 15:38:34 · 675 阅读 · 2 评论 -
Nim Game——Difficulty:Easy
Problem :You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone wil原创 2016-09-04 15:57:51 · 545 阅读 · 1 评论 -
Counting Bits——Difficulty:Medium
Problem :Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1’s in their binary representation and return them as an array.Example:For `num =原创 2016-09-04 16:44:05 · 228 阅读 · 1 评论 -
Construct Binary Tree from Inorder and Postorder Traversal——Difficulty:Medium
Problem :Given inorder and postorder traversal of a tree, construct the binary tree.Example:**Algorithm:** 已知的二叉树的中序遍历和后序遍历,构造二叉树。 图1 以图1为例, 中序遍历:DBEAFC 后序遍历:DEBFCA 可以发现后序遍历的最后一个节点是根节点,而在中序遍历中,这个原创 2016-09-06 13:14:41 · 308 阅读 · 1 评论 -
Kth Smallest Element in a BST——Difficulty:Medium
Problem :Given a binary search tree, write a function kthSmallest to find the kth smallest element in it.Note: You may assume k is always valid, 1 ≤ k ≤ BST’s total elements.Follow up: What if the B原创 2016-09-21 16:14:26 · 213 阅读 · 0 评论 -
Convert Sorted Array to Binary Search Tree——Difficulty:Medium
Problem :Given an array where elements are sorted in ascending order, convert it to a height balanced BST.Example:**Algorithm:** 根据二叉平衡搜索树的特点,因为这个数组是有序的,所以可以把数组分成两半,左边一半世左子树,右边一半是右子树,中间的是根节点,然后对每一半的数组原创 2016-09-21 16:38:17 · 469 阅读 · 0 评论 -
Remove Invalid Parentheses——Difficulty:Hard
Problem :Remove the minimum number of invalid parentheses in order to make the input string valid. Return all possible results.Note: The input string may contain letters other than the parentheses ( an原创 2016-10-10 19:10:46 · 322 阅读 · 1 评论 -
Decode String
Problem :Given an encoded string, return it’s decoded string.The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. Note that k原创 2017-01-07 16:35:12 · 283 阅读 · 0 评论