There are N gas stations along a circular route, where the amount of gas at station i is&n…
标签:LeetCode题目解答汇总
LeetCode | Candy(分糖果问题)
There are N children standing in a line. Each child is assigned a rating value. You are giving candi…
LeetCode | Single Number(数组中的单个数字)
Given an array of integers, every element appears twice except for one. Find that single one. Note: …
LeetCode | Single Number II(单个数字II)
Given an array of integers, every element appears three times except for one. Find that single one. …
LeetCode | Linked List Cycle(判断链表是否有环)
Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using extra space?…
LeetCode | 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 …
LeetCode | Insertion Sort List(插入法排序链表)
Sort a linked list using insertion sort. 题目解析: 链表思路不难,但是指针比较麻烦,要细心才行。这道题让我调了半天,原来是一个指针赋错了,因为用的变量p和q,导致很长时间才发现……
LeetCode | Evaluate Reverse Polish Notation(逆波兰式求值)
Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +,&nb…
LeetCode | 3Sum(三个数的和等于0)
Given an array S of n integers, are there elements a, b, c in S&n…
LeetCode | Reverse Words in a String(字符串中的单词序反转)
Given an input string, reverse the string word by word. For example, Given s = “the sky is blue“, …
LeetCode | 3Sum Closest(找到三个数使其和与target最接近)
Given an array S of n integers, find three integers in S such that the sum is cl…
LeetCode | 4Sum(四个数的和)
Given an array S of n integers, are there elements a, b, c, and d …