Given a linked list, swap every two adjacent nodes and return its head. Example: Given 1->2->…
分类:LeetCode题目解答
[LeetCode] Search in Rotated Sorted Array II 在旋转有序数组中搜索之二, Search in Rotated Sorted Array 在旋转有序数组中搜索, Search in Rotated Sorted Array 在旋转有序数组中搜索
Follow up for “Search in Rotated Sorted Array”:What if duplicates are allowed? Wo…
[LeetCode] Random Pick with Weight 根据权重随机取点
Given an array w of positive integers, where w[i] describes the weight of index&nbs…
LeetCode 232 Implement Queue using Stacks
题目描述 Implement the following operations of a queue using stacks. push(x) – Push element x to the back of queue…
995. Minimum Number of K Consecutive Bit Flips
In an array A containing only 0s and 1s, a K-bit flip consists of choosing a (contiguous) subarray of length K…
165. Compare Version Numbers
Compare two version numbers version1 and version2.If version1 > version2 return 1; if version1 < version…
[LeetCode] Best Time to Buy and Sell Stock 买卖股票的最佳时间
Say you have an array for which the ith element is the price of a given stock on day i. …
[LeetCode] Verify Preorder Serialization of a Binary Tree 验证二叉树的先序序列化
One way to serialize a binary tree is to use pre-oder traversal. When we encounter a non-null node, we …
[LeetCode] Reverse String 翻转字符串
Write a function that takes a string as input and returns the string reversed. Example: Given s = ̶…
[LeetCode] Base 7 基数七
Given an integer, return its base 7 string representation. Example 1: Input: 100 Output: "202" E…
[LeetCode] Bold Words in String 字符串中的加粗单词
Given a set of keywords words and a string S, make all appearances of all keywords in&nb…
75. Sort Colors,【LeetCode】75. Sort Colors (3 solutions)
75. Sort Colors 题目 Given an array with n objects colored red, white or blue, sort them so that objects of the …