题目描述 You are a product manager and currently leading a team to develop a new product. Unfortunately, the lates…
分类:LeetCode题目解答
[Leetcode] Find the Duplicate Number 找到重复数字
Find the Duplicate Number Given an array nums containing n + 1 integers where each integer is between 1 and n …
LeetCode 13. Roman to Integer
Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. Su…
LeetCode 114| Flatten Binary Tree to Linked List(二叉树转化成链表)
题目 给定一个二叉树,原地将它展开为链表。 例如,给定二叉树 1 / \ 2 5 / \ \ 3 4 6 将其展开为: 1 \ 2 \ 3 \ 4 \ 5 \ 6 解析 通过递归实现;可以用先序遍历,然后串成链表 主要思…
LeetCode 016 3Sum Closest
题目描述 Given an array S of n integers, find three integers in S such that the sum is closest to a given number, …
[Algo] Constant Time Random Picker 获取集合内随机元素
Constant Time Random Picker 设计一个数据结构,支持O(1)时间的查询,增加,删除,和得到其中随机元素的操作,可以认为其中的元素是数字。 哈希表数组 复杂度 时间 O(1) 空间 O(N) 思路…
【leetcode】4. Median of Two Sorted Arrays 两个有序数组组成集合的中位数
1. 题目 There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sor…
[LeetCode] Expression Add Operators 表达式增加操作符,Combination Sum II 组合之和之二
Given a string that contains only digits 0-9 and a target value, return all possibilities to …
[LeetCode] Lexicographical Numbers 字典顺序的数字
Given an integer n, return 1 – n in lexicographical order. For example, given 13, return: [1,10,1…
LeetCode | Swap Nodes in Pairs
题目: Given a linked list, swap every two adjacent nodes and return its head. For example, Given 1->2-&g…
[LeetCode] Reverse Words in a String III 翻转字符串中的单词之三
Given a string, you need to reverse the order of characters in each word within a sentence while still …
[LeetCode] Palindrome Permutation II 回文全排列之二
Given a string s, return all the palindromic permutations (without duplicates) of it. Return an em…