![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode
seucxt
这个作者很懒,什么都没留下…
展开
-
【leetcode】ZigZag Conversion
The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H NA P L S I I原创 2016-12-01 22:50:57 · 149 阅读 · 0 评论 -
Construct Binary Tree from Preorder and Inorder Traversal
Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.本题采用递归的方式来进行:/** * Definition for a binary tree node. *原创 2017-06-10 17:01:20 · 185 阅读 · 0 评论 -
Binary Tree Zigzag Level Order Traversal
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).For example:Given binary tr原创 2017-06-10 16:33:03 · 147 阅读 · 0 评论 -
Combinations
Given two integers n and k, return all possible combinations ofk numbers out of 1 ... n.For example,If n = 4 and k = 2, a solution is:[ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4],]原创 2017-06-10 15:53:44 · 170 阅读 · 0 评论 -
Set Matrix Zeroes
Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.click to show follow up.Follow up:Did you use extra space?A straight forward solution using O(mn) s原创 2017-06-10 15:42:02 · 123 阅读 · 0 评论 -
Reverse Linked List II
Reverse a linked list from position m to n. Do it in-place and in one-pass.For example:Given 1->2->3->4->5->NULL, m = 2 and n = 4,return 1->4->3->2->5->NULL.Note:Given m, n satisfy the follo原创 2017-06-10 15:05:43 · 116 阅读 · 0 评论 -
Search a 2D Matrix
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted from left to right.The first integer of each原创 2017-06-10 14:34:26 · 113 阅读 · 0 评论 -
全排列问题 java
经常会遇到字符串全排列的问题。例如:输入为{‘a’,’b’,’c’},则其全排列组合为abc,acb,bac,bca,cba,cab。对于输入长度为n的字符串数组,全排列组合为n!种。思路:从字符串数组中每次选取一个元素,作为结果中的第一个元素。然后,对剩余的元素全排列,步骤跟上面一样。很明显这是个递归处理的过程,一直到最后即可。public class Main { publi原创 2017-06-10 14:09:49 · 212 阅读 · 0 评论 -
【leetcode】Longest Common Prefix
Longest Common PrefixWrite a function to find the longest common prefix string amongst an array of strings.问题分析: (1) 对于这个问题,首先处理特殊字符串,对于[] 和[""]等字符串要优先处理,输出“”,对于字符串数组中只有一个字符串的情况,那么它自己本身就是最长原创 2016-12-02 11:18:06 · 178 阅读 · 0 评论 -
Construct Binary Tree from Inorder and Postorder Traversal
Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree./** * Definition for a binary tree node. * public class原创 2017-06-10 17:11:22 · 196 阅读 · 0 评论