![](https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法面试
Lee_Wei4939
本人具有扎实的计算机理论基础,严谨的逻辑思维,深刻理解数据结构与算法、操作系统和计算机网络
展开
-
LeetCode力扣之Valid Parentheses
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" are all valid but ...原创 2018-03-04 20:34:43 · 102 阅读 · 0 评论 -
LeetCode力扣之Next Permutation
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest possible ord...原创 2018-03-06 11:41:53 · 191 阅读 · 0 评论 -
LeetCode力扣之92. 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,...原创 2018-03-13 15:35:35 · 148 阅读 · 0 评论 -
LeetCode力扣之Restore IP Addresses
Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given "25525511135",return ["255.255.11.135", "255.255.111.35"]. (Order does not m...原创 2018-03-13 16:53:28 · 172 阅读 · 0 评论 -
LeetCode力扣之Longest Valid Parentheses
Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the longest valid parentheses substring is "()", which ha...原创 2018-03-06 15:37:46 · 104 阅读 · 0 评论 -
LeetCode力扣之95. Unique Binary Search Trees II
Given an integer n, generate all structurally unique BST's (binary search trees) that store values 1...n.For example,Given n = 3, your program should return all 5 unique BST's shown below. 1 ...原创 2018-03-13 20:18:13 · 173 阅读 · 0 评论 -
LeetCode力扣之97. Interleaving String
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", return false.packag...原创 2018-03-13 21:56:20 · 219 阅读 · 0 评论 -
LeetCode力扣之99. Recover Binary Search Tree
Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A solution using O(n) space is pretty straight forward. Could you devise a consta...原创 2018-03-14 16:35:48 · 215 阅读 · 0 评论 -
111. Minimum Depth of Binary Tree
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 leaf node.package leetCode;/** * Created by lxw, ...原创 2018-03-24 20:09:11 · 127 阅读 · 0 评论 -
LeetCode力扣之112. Path Sum
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.For example:Given the below binary tree and sum = 22...原创 2018-03-24 20:26:18 · 153 阅读 · 0 评论 -
LeetCode力扣之Decode Ways
A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message containing digits, determine the total n...原创 2018-03-13 11:48:43 · 118 阅读 · 0 评论 -
LeetCode力扣之Substring with Concatenation of All Words
You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a concatenation of each word in words exactly once and wi...原创 2018-03-06 10:31:59 · 130 阅读 · 0 评论 -
leetCode力扣之Generate Parentheses
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:[ "((()))", "(()())", "(())()", "()(())", "...原创 2018-03-05 10:59:11 · 247 阅读 · 0 评论 -
LeetCode力扣之Largest Rectangle in Histogram
Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.Above is a histogram where width of each bar...原创 2018-03-12 15:29:59 · 145 阅读 · 0 评论 -
IntelliJ IDEA 常用快捷键
编辑快捷键介绍Tab缩进 / 配合代码提示实现自动完成Shift + Tab取消缩进Ctrl + Z撤销Ctrl + Shift + Z取消撤销Ctrl + Y删除光标所在行 或 删除选中的行Ctrl + X剪切光标所在行 或 剪切选择内容Ctrl + C复制光标所在行 或 复制选择内容Ctrl + V在光标所在处粘贴已复制内容Ctrl + Shift + V弹出历史复制内容Ctrl + D复制光...转载 2018-03-05 14:22:24 · 251 阅读 · 0 评论 -
LeetCode力扣之Merge k Sorted Lists
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.import java.util.ArrayList;import java.util.Comparator;import java.util.List;/** * Created by lxw...原创 2018-03-05 15:11:08 · 164 阅读 · 0 评论 -
LeetCode力扣之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 the...原创 2018-03-12 17:09:04 · 152 阅读 · 0 评论 -
LeetCode力扣之Reverse Nodes in k-Group
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.k is a positive integer and is less than or equal to the length of the linked list. If the number of no...原创 2018-03-05 19:59:15 · 163 阅读 · 0 评论 -
leetCode力扣之Remove Element
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 must do this by modifying the input array in-place ...原创 2018-03-05 20:36:16 · 182 阅读 · 0 评论 -
LeetCode力扣之Subsets II
Given a collection of integers that might contain duplicates, nums, return all possible subsets (the power set).Note: The solution set must not contain duplicate subsets.For example,If nums = [1,2,2],...原创 2018-03-12 22:57:23 · 126 阅读 · 0 评论 -
LeetCode力扣之Implement strStr()
Implement strStr().Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Example 1:Input: haystack = "hello", needle = "ll"Output: 2Example 2:Input:...原创 2018-03-05 21:02:38 · 161 阅读 · 0 评论 -
LeetCode力扣之113. Path Sum II
Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tree and sum = 22, 5 / \ ...原创 2018-03-24 21:35:18 · 192 阅读 · 0 评论 -
LeetCode力扣之115. Distinct Subsequences
Given a string S and a string T, count the number of distinct subsequences of S which equals T.A subsequence of a string is a new string which is formed from the original string by deleting some (can ...原创 2018-03-25 09:36:17 · 226 阅读 · 0 评论 -
LeetCode力扣之109. Convert Sorted List to Binary Search Tree
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.For this problem, a height-balanced binary tree is defined as a binary tree in which the de...原创 2018-03-21 18:03:25 · 142 阅读 · 0 评论 -
LeetCode力扣之126. Word Ladder II
Given two words (beginWord and endWord), and a dictionary's word list, find all shortest transformation sequence(s) from beginWord to endWord, such that:Only one letter can be changed at a timeEach tr...原创 2018-03-26 10:51:26 · 470 阅读 · 0 评论 -
LeetCode力扣之128. Longest Consecutive Sequence
Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given [100, 4, 200, 1, 3, 2],The longest consecutive elements sequence is [1, 2, 3, 4]. Re...原创 2018-03-26 13:39:55 · 269 阅读 · 0 评论 -
LeetCode力扣之129. Sum Root to Leaf Numbers
Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which represents the number 123.Find the total su...原创 2018-03-26 14:10:48 · 176 阅读 · 0 评论 -
LeetCode力扣之130. Surrounded Regions
Given a 2D board containing 'X' and 'O' (the letter O), capture all regions surrounded by 'X'.A region is captured by flipping all 'O's into 'X's in that surrounded region.For example,X X X XX O O X...原创 2018-03-26 17:28:48 · 271 阅读 · 0 评论 -
LeetCode力扣之131. Palindrome Partitioning
Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For example, given s = "aab",Return[ ["aa","b"], ["a","a",...原创 2018-03-26 20:17:13 · 245 阅读 · 0 评论 -
LeetCode力扣之132. Palindrome Partitioning II
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 1 since t...原创 2018-03-26 21:13:37 · 287 阅读 · 0 评论 -
133. Clone Graph
Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.OJ's undirected graph serialization:Nodes are labeled uniquely.We use # as a separator for each node, and...原创 2018-03-26 22:21:22 · 225 阅读 · 0 评论 -
LeetCode力扣之135. Candy
There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child must have at least one candy....原创 2018-03-27 10:17:07 · 451 阅读 · 1 评论 -
LeetCode力扣之108. Convert Sorted Array to Binary Search Tree
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the t...原创 2018-03-21 16:54:44 · 218 阅读 · 0 评论 -
LeetCode力扣之107. Binary Tree Level Order Traversal II
Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For example:Given binary tree [3,9,20,null,null,15,7], ...原创 2018-03-21 16:09:56 · 140 阅读 · 0 评论 -
LeetCode力扣之116. Populating Next Right Pointers in Each Node
Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointer to point to its next right node. If there i...原创 2018-03-25 11:18:27 · 176 阅读 · 0 评论 -
LeetCode力扣之103. 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 tree [...原创 2018-03-21 10:54:54 · 148 阅读 · 0 评论 -
LeetCode力扣之117. Populating Next Right Pointers in Each Node II
Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your previous solution still work?Note:You may only use constant extra space....原创 2018-03-25 16:33:55 · 178 阅读 · 0 评论 -
LeetCode力扣之119. Pascal's Triangle II
Given an index k, return the kth row of the Pascal's triangle.For example, given k = 3,Return [1,3,3,1].Note:Could you optimize your algorithm to use only O(k) extra space?package leetCode;import ja...原创 2018-03-25 17:10:55 · 229 阅读 · 0 评论 -
LeetCode力扣之120. Triangle
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], [6,5,7],...原创 2018-03-25 20:19:40 · 152 阅读 · 0 评论 -
LeetCode力扣之121. Best Time to Buy and Sell Stock
Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock), des...原创 2018-03-25 20:50:24 · 193 阅读 · 0 评论