LeetCode #31 – Next Permutation [next_permutation函数原理]


Link 传送门 Problem 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 order (ie, sorted in ascendin...

LeetCode #31 – Next Permutation [next_permutation函数原理]

Link 传送门 Problem Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such ar...
阅读全文 0

LeetCode #30 – Substring with Concatenation of All Words [map]


Link 传送门 Problem 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 wordsexactly once and without any intervening charac...

LeetCode #30 – Substring with Concatenation of All Words [map]

Link 传送门 Problem 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(...
阅读全文 0

LeetCode #29 – Divide Two Integers [思路]


Link 点击打开题目链接 Problem Divide two integers without using multiplication, division and mod operator. If it is overflow, return MAX_INT. Mean 计算INT内的两个数相除,不能使用乘法、除法和取模。 Analysis 首先想到除法变成减法,但是减法太慢了。这...

LeetCode #29 – Divide Two Integers [思路]

Link 点击打开题目链接 Problem Divide two integers without using multiplication, division and mod operator. If it is overflow, return MAX_INT. Mean ...
阅读全文 0

LeetCode #27 – Remove Element [数组操作]


Link 点击打开题目链接 Problem Given an array and a value, remove all instances of that value in place and return the new length. The order of elements can be changed. It doesn’t matter what you leave beyond the new length. Mean 给你一个整数...

LeetCode #27 – Remove Element [数组操作]

Link 点击打开题目链接 Problem Given an array and a value, remove all instances of that value in place and return the new length. The order of eleme...
阅读全文 0

LeetCode #26 – Remove Duplicates from Sorted Array [数组操作]


Link 点击打开题目链接 Problem Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate extra space for another array, you must do this in place with constant memory. Fo...

LeetCode #26 – Remove Duplicates from Sorted Array [数组操作]

Link 点击打开题目链接 Problem Given a sorted array, remove the duplicates in place such that each element appear only once and return the new lengt...
阅读全文 0

LeetCode #24 – Swap Nodes in Pairs [指针的指针]


链接:https://leetcode.com/problems/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 shoul...

LeetCode #24 – Swap Nodes in Pairs [指针的指针]

链接:https://leetcode.com/problems/swap-nodes-in-pairs/ 题目: Given a linked list, swap every two adjacent nodes and return its head. For example...
阅读全文 0

LeetCode #23 – Merge k Sorted Lists [二分]


链接:https://leetcode.com/problems/merge-k-sorted-lists/ 题目:Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 题意:给定k个有序链表,合并成一个有序链表 分析:类似上个合并两个链表的题目,对于k个...

LeetCode #23 – Merge k Sorted Lists [二分]

链接:https://leetcode.com/problems/merge-k-sorted-lists/ 题目:Merge k sorted linked lists and return it as one sorted list. Analyze and describe ...
阅读全文 0

LeetCode #22 – Generate Parentheses [DFS]


链接:https://leetcode.com/problems/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: "((()))", "(()())", "(())()", "()...

LeetCode #22 – Generate Parentheses [DFS]

链接:https://leetcode.com/problems/generate-parentheses/ 题目: Given n pairs of parentheses, write a function to generate all combinations of wel...
阅读全文 0

LeetCode #21 – Merge Two Sorted Lists


链接:https://leetcode.com/problems/merge-two-sorted-lists/ 题目:Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. 题意:给定两个有序链表,合并成新的有序...

LeetCode #21 – Merge Two Sorted Lists

链接:https://leetcode.com/problems/merge-two-sorted-lists/ 题目:Merge two sorted linked lists and return it as a new list. The new list should be...
阅读全文 0

LeetCode #20 – Valid Parentheses [Stack]


链接:https://leetcode.com/problems/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 "()[]{}" ar...

LeetCode #20 – Valid Parentheses [Stack]

链接:https://leetcode.com/problems/valid-parentheses/ 题目: Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determ...
阅读全文 0