题目: There are N gas stations along a circular route, where the amount of gas at station i …
分类:LeetCode
【leetcode】50. Pow(x, n) 幂计算
1. 题目 Implement pow(x, n). 2. 思路 每次翻倍,如果当前翻倍的幂次在n的二进制位内,则乘入最后结果中,否则跳过继续。特殊场景较多,要特别考虑: 幂次n可能是负数,这是要注意转换为正数后,最后求…
LeetCode677. Map Sum Pairs
Analysis Brute-force solution Apparently, a straightforward brute-force solution would be to store every {key,…
125. Valid Palindrome My Submissions Question
/* 125. Valid Palindrome My Submissions Question Total Accepted: 94559 Total Submissions: 401331 Difficulty: E…
Leetcode - Count of Smaller Numbers After Self
My code: import java.util.Arrays; import java.util.List; public class Solution { class Node { int val = 0; int…
360. Sort Transformed Array
Given a sorted array of integers nums and integer values a, b and c. Apply a function of the form f(x) = ax2 +…
[LeetCode By Go 102]141. Linked List Cycle
这道题不能用go写,所以用C语言写的 题目 Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it with…
[LeetCode] Generalized Abbreviation 通用简写
Write a function to generate the generalized abbreviations of a word. Example: Given word = "word"…
[LeetCode] Number of Connected Components in an Undirected Graph 无向图中的连通区域的个数
Given n nodes labeled from 0 to n – 1 and a list of undirected edges (each edge is a pair of node…
[LeetCode] Circular Array Loop 环形数组循环
You are given an array of positive and negative integers. If a number n at an index is positive, then m…
[LeetCode] Max Consecutive Ones II 最大连续1的个数之二
Given a binary array, find the maximum number of consecutive 1s in this array if you can flip at most o…
Leetcode282. Expression Add Operators
Analysis Oveiously, in order to solve this question, we have to iterate through all of the possible cases at l…