代码改变世界

[LeetCode] 46. Permutations_Medium tag: DFS, backtracking

2019-05-24 09:27 by Johnson_强生仔仔, 263 阅读, 0 推荐, 收藏, 编辑
摘要:Given a collection of distinct integers, return all possible permutations. Example: Input: [1,2,3] Output: [ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1, 阅读全文

[LeetCode] 146. LRU Cache_Hard tag: Hash, Linked List

2019-05-18 11:10 by Johnson_强生仔仔, 185 阅读, 0 推荐, 收藏, 编辑
摘要:Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and put. get(key) - Get the 阅读全文

[LeetCode] 128. Longest Consecutive Sequence_Hard tag: Hash 思路:记忆化搜索

2019-05-16 07:31 by Johnson_强生仔仔, 283 阅读, 0 推荐, 收藏, 编辑
摘要:Given an unsorted array of integers, find the length of the longest consecutive elements sequence. Your algorithm should run in O(n) complexity. Examp 阅读全文

[LeetCode] 654. Maximum Binary Tree_Medium tag: stack

2019-05-15 09:24 by Johnson_强生仔仔, 187 阅读, 0 推荐, 收藏, 编辑
摘要:Given an integer array with no duplicates. A maximum tree building on this array is defined as follow: Construct the maximum tree by the given array a 阅读全文

[LeetCode] 84. Largest Rectangle in Histogram_Hard tag: stack

2019-05-15 00:20 by Johnson_强生仔仔, 221 阅读, 0 推荐, 收藏, 编辑
摘要: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 hist 阅读全文

[LeetCode] 232. Implement Queue using Stacks_Easy tag: stack

2019-05-13 05:37 by Johnson_强生仔仔, 269 阅读, 0 推荐, 收藏, 编辑
摘要:Implement the following operations of a queue using stacks. push(x) -- Push element x to the back of queue. pop() -- Removes the element from in front 阅读全文

[LeetCode] 155. Min Stack_Easy tag: stack

2019-05-13 04:53 by Johnson_强生仔仔, 228 阅读, 0 推荐, 收藏, 编辑
摘要:Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) -- Push element x onto stack. pop() -- Remov 阅读全文

[LeetCode] 系统刷题8_Data Structure

2019-05-13 04:21 by Johnson_强生仔仔, 285 阅读, 0 推荐, 收藏, 编辑
摘要:Linear data structure Queue used for BFS most of time O(1) for push O(1) for Pop O(1) for Top Stack . 得到第一个左边比该点小的,第一个右边比该点小的 => strict increasing sta 阅读全文

[LeetCode] 75. Sort Colors_Medium tag: Two pointers

2019-05-12 10:22 by Johnson_强生仔仔, 328 阅读, 0 推荐, 收藏, 编辑
摘要:Given an array with n objects colored red, white or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the or 阅读全文

[LeetCode] 15. 3Sum_Medium tag: Array

2019-05-12 03:51 by Johnson_强生仔仔, 226 阅读, 0 推荐, 收藏, 编辑
摘要:Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the s 阅读全文
上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 39 下一页