![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LeetCode
qufayudao
这个作者很懒,什么都没留下…
展开
-
LeetCode 137. Single Number II
描述Given an array of integers, every element appears three times except for one, which appears exactly once. Find that single one.Note: Your algorithm should have a linear runtime complexity. Co...原创 2018-03-17 21:53:24 · 145 阅读 · 0 评论 -
LeetCode 152. Maximum Product Subarray
描述Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array [2,3,-2,4], the contiguous subarray [2,3] has the larg...原创 2018-03-25 16:49:02 · 196 阅读 · 0 评论 -
LeetCode 151. Reverse Words in a String
描述Given an input string, reverse the string word by word.For example, Given s = “the sky is blue”, return “blue is sky the”.Update (2015-02-12): For C programmers: Try to solve it in-place ...原创 2018-03-24 18:37:27 · 190 阅读 · 0 评论 -
LeetCode 150. Evaluate Reverse Polish Notation
描述Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or another expression.Some examples: ["2", "1", "+...原创 2018-03-23 18:17:16 · 144 阅读 · 0 评论 -
LeetCode 148. Sort List
描述 Sort a linked list in O(n log n) time using constant space complexity.思路 排序算法有很多,对链表进行排序可以选择比较容易操作的算法,这里选择快速排序法,因为快速排序法比较容易用链表实现。快速排序法的思想:对未排序链表进行遍历,每次找出最小的元素位置,将最小的元素与未排序的第一个元素进行交换,继续遍历,知道所有的元...原创 2018-03-23 16:12:22 · 113 阅读 · 0 评论 -
LeetCode 147. Insertion Sort List
描述 Sort a linked list using insertion sort.思路 首先要明白直接插入排序的概念:遍历一个数组,当找到一个数a,该数比前一个数更小,则将a之前的所有大于a的数全部向前移动1,将a插入最后一个大于该数的位置。用数组排序的代码如下代码(c#) public void InsertSort(int[] arr) { ...原创 2018-03-22 23:56:56 · 106 阅读 · 0 评论 -
LeetCode 143. Reorder List
描述 Given a singly linked list L: L0→L1→…→Ln-1→Ln, reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes’ values.For example, Given {1,2,3,4}, reorder it t...原创 2018-03-22 15:11:25 · 129 阅读 · 0 评论 -
LeetCode 144. Binary Tree Preorder Traversal
描述Given a binary tree, return the preorder traversal of its nodes’ values. For example: Given binary tree [1,null,2,3], 1 \ 2 / 3return [1,2,3].Note: Recursive solution i...原创 2018-03-22 22:13:13 · 157 阅读 · 0 评论 -
LeetCode 142. Linked List Cycle II
描述 Given a linked list, return the node where the cycle begins. If there is no cycle, return null.Note: Do not modify the linked list.Follow up: Can you solve it without using extra space?思...原创 2018-03-18 15:50:50 · 234 阅读 · 0 评论 -
139. Word Break
描述 Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words. You may...原创 2018-03-18 14:38:30 · 166 阅读 · 0 评论 -
LeetCode 153. Find Minimum in Rotated Sorted Array
描述Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).Find the minimum element.You may assume no du...原创 2018-03-25 17:59:56 · 164 阅读 · 0 评论