JinFei's Blog

Thinking will not overcome fear but action will.

[LeetCode]324. Wiggle Sort II

排列数组成指定形式

题目描述 Given an unsorted array nums, reorder it such that nums[0] < nums[1] > nums[2] < nums[3]…. Example1: Input: nums = [1, 5, 1, 1, 6, 4] Output: One possible answer is [1,...

[LeetCode]8. String to Integer (atoi)

实现自己的string2int

题目描述 Implement atoi which converts a string to an integer. The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starti...

[LeetCode]130. Surrounded Regions

dfs搜索

题目描述 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. Example1...

[LeetCode]334. Increasing Triplet Subsequence

递增的三元组

题目描述 Given an unsorted array return whether an increasing subsequence of length 3 exists or not in the array. Formally the function should: Return true if there exists i, j, k such that arr...

[LeetCode]210. Course Schedule II

图的遍历

题目描述 There are a total of n courses you have to take, labeled from 0 to n-1. Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expr...

[LeetCode]38. Count and Say***

读数

题目描述 The count-and-say sequence is the sequence of integers with the first five terms as following: 1. 1 2. 11 3. 21 4. 1211 5. 111221 <br> 1 is ...

[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 t...

[LeetCode]122. Best Time to Buy and Sell Stock II

dp,获取最大利润

题目描述 Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete as many transactions as you lik...

[LeetCode]621. Task Scheduler

分块,组合

题目描述 Given a char array representing tasks CPU need to do. It contains capital letters A to Z where different letters represent different tasks. Tasks could be done without original order. Each ...

[LeetCode]114. Flatten Binary Tree to Linked List

将二叉树转为链表

题目描述 Given a binary tree, flatten it to a linked list in-place. 1 / 2 5 / \ 3 4 6 The flattened tree should look like: 1 2 3 4 5 ...