
LeetCode
jiangwayne
这个作者很懒,什么都没留下…
展开
-
LeetCode Q4寻找两个正序数组的中位数
官方解答给定两个大小为 m 和 n 的正序(从小到大)数组nums1 和nums2。请你找出这两个正序数组的中位数,并且要求算法的时间复杂度为O(log(m + n))。你可以假设nums1和nums2不会同时为空。示例 1:nums1 = [1, 3]nums2 = [2]则中位数是 2.0示例 2:nums1 = [1, 2]nums2 = [3, 4]则中位数是 (2 + 3)/2 = 2.5public double findMedia...原创 2020-07-14 00:55:10 · 181 阅读 · 0 评论 -
LeetCode Q3无重复字符的最长子串
给定一个字符串,请你找出其中不含有重复字符的最长子串的长度。示例1:输入: "abcabcbb"输出: 3解释: 因为无重复字符的最长子串是 "abc",所以其长度为 3。示例 2:输入: "bbbbb"输出: 1解释: 因为无重复字符的最长子串是 "b",所以其长度为 1。示例 3:输入: "pwwkew"输出: 3解释: 因为无重复字符的最长子串是"wke",所以其长度为 3。 请注意,你的答案必须是 子串 的长度,"pwke"是一个子序列,不是子串...原创 2020-07-13 23:57:11 · 166 阅读 · 0 评论 -
LeetCode Q2 两数相加
给出两个非空 的链表用来表示两个非负的整数。其中,它们各自的位数是按照逆序的方式存储的,并且它们的每个节点只能存储一位数字。如果,我们将这两个数相加起来,则会返回一个新的链表来表示它们的和。您可以假设除了数字 0 之外,这两个数都不会以 0开头。示例:输入:(2 -> 4 -> 3) + (5 -> 6 -> 4)输出:7 -> 0 -> 8原因:342 + 465 = 807 public ListNode addTwoNum...原创 2020-07-13 23:56:12 · 135 阅读 · 0 评论 -
LeetCode Q1 两数之和
给定一个整数数组 nums和一个目标值 target,请你在该数组中找出和为目标值的那两个整数,并返回他们的数组下标。你可以假设每种输入只会对应一个答案。但是,数组中同一个元素不能使用两遍。示例:给定 nums = [2, 7, 11, 15], target = 9因为 nums[0] + nums[1] = 2 + 7 = 9所以返回 [0, 1] public int[] twoSum(int[] nums, int target) { Map...原创 2020-07-13 23:54:29 · 173 阅读 · 0 评论 -
LeetCode -- 292. Nim Game
You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will be the原创 2016-04-19 23:52:38 · 289 阅读 · 0 评论 -
LeetCode -- 342. Power of Four
Given an integer (signed 32 bits), write a function to check whether it is a power of 4.Example:Given num = 16, return true. Given num = 5, return false.Follow up: Could you solve it without原创 2016-04-19 23:55:27 · 279 阅读 · 0 评论