![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Leetcode
luxialan
这个作者很懒,什么都没留下…
展开
-
Maximum Depth of Binary Tree
Maximum Depth of Binary Tree Total Accepted: 36406 Total Submissions: 83130 Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path f原创 2014-10-29 21:16:58 · 476 阅读 · 0 评论 -
八皇后问题和数独问题
八皇后问题和数独问题是经典dfs+回溯的问题,其中还可以涉及hash,是非常好的练习题目。我们以leetcode中的四道题目为例。 Valid Sudoku Total Accepted: 40598 Total Submissions: 149092 Determine if a Sudoku is valid The Sudoku board c原创 2015-07-18 09:13:58 · 1216 阅读 · 0 评论 -
链表的反转问题(Reverse Linked List)
反转单链表思路有三种, 1.将1->2->3变为原创 2015-07-30 10:17:19 · 961 阅读 · 0 评论 -
Find Minimum in Rotated Sorted Array II
Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). Find the minimum element. The array may contain duplicates. 二原创 2015-01-03 10:57:20 · 409 阅读 · 0 评论 -
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 4 5 6 7 0 1 2). Find the minimum element. You may assume no duplicate exists in原创 2015-01-03 10:23:33 · 384 阅读 · 0 评论 -
Sort Colors
Sort Colors Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue. Here, we wi原创 2015-01-18 09:30:29 · 430 阅读 · 0 评论 -
Excel Sheet Column Title
Excel Sheet Column Title Given a positive integer, return its corresponding column title as appear in an Excel sheet. For example: 1 -> A 2 -> B 3 -> C ... 26 -> Z 2原创 2015-01-15 11:08:02 · 433 阅读 · 0 评论 -
Excel Sheet Column Number
Given a column title as appear in an Excel sheet, return its corresponding column number. For example: A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -> 28 水题 clas原创 2015-01-15 11:15:21 · 371 阅读 · 0 评论 -
Dungeon Game
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. Our valiant knight (K) was initially p原创 2015-01-15 09:10:22 · 426 阅读 · 0 评论 -
N-Queens II
Follow up for N-Queens problem. Now, instead outputting board configurations, return the total number of distinct solutions. 八皇后问题拖了好久才解决,用的是回溯法的思路,可以用非递归的方法实现,本质上是用栈来实现深度遍历 class Solutio原创 2014-12-24 14:17:29 · 458 阅读 · 0 评论 -
Unique Binary Search Trees
Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For example, Given n = 3, there are a total of 5 unique BST's. 1 3 3 2 1 \原创 2014-12-07 11:30:20 · 383 阅读 · 0 评论 -
Swap Nodes in Pairs
Given a linked list, swap every two adjacent nodes and return its head. For example, Given 1->2->3->4, you should return the list as 2->1->4->3. Your algorithm should use only constant space. Y原创 2014-12-06 19:58:44 · 418 阅读 · 0 评论 -
Convert Sorted Array to Binary Search Tree
Convert Sorted Array to Binary Search Tree Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 这道题本质上是二分搜索+递归建立二叉树 /** * Definition for binary原创 2014-12-07 10:49:34 · 393 阅读 · 0 评论 -
Search Insert Position
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 order. You may assume no duplicates in the array.原创 2014-12-06 16:18:16 · 429 阅读 · 0 评论 -
KSum问题
KSum是Leetcode上的一系列问题,本质上还是hash问题。现在从最基本的2Sum开始拓展到KSum. Two Sum Total Accepted: 112324 Total Submissions: 635568 Given an array of integers, find two numbers such that they add up to a原创 2015-07-20 16:55:46 · 816 阅读 · 0 评论