jzoffer

package
v0.0.0-...-6c0d317 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 15, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

* @lc app=leetcode.cn id=137 lang=golang * * [137] 只出现一次的数字 II * * https://leetcode.cn/problems/single-number-ii/description/ * * algorithms * Medium (72.11%) * Likes: 893 * Dislikes: 0 * Total Accepted: 129.8K * Total Submissions: 180K * Testcase Example: '[2,2,3,2]' * * 给你一个整数数组 nums ,除某个元素仅出现 一次 外,其余每个元素都恰出现 三次 。请你找出并返回那个只出现了一次的元素。 * * * * 示例 1: * * * 输入:nums = [2,2,3,2] * 输出:3 * * * 示例 2: * * * 输入:nums = [0,1,0,1,0,1,99] * 输出:99 * * * * * 提示: * * * 1 * -2^31 * nums 中,除某个元素仅出现 一次 外,其余每个元素都恰出现 三次 * * * * * 进阶:你的算法应该具有线性时间复杂度。 你可以不使用额外空间来实现吗? *

* @lc app=leetcode.cn id=167 lang=golang * * [167] 两数之和 II - 输入有序数组 * * https://leetcode.cn/problems/two-sum-ii-input-array-is-sorted/description/ * * algorithms * Medium (58.77%) * Likes: 857 * Dislikes: 0 * Total Accepted: 462.1K * Total Submissions: 786.1K * Testcase Example: '[2,7,11,15]\n9' * * 给你一个下标从 1 开始的整数数组 numbers ,该数组已按 非递减顺序排列  ,请你从数组中找出满足相加之和等于目标数 target * 的两个数。如果设这两个数分别是 numbers[index1] 和 numbers[index2] ,则 1 <= index1 < index2 <= * numbers.length 。 * * 以长度为 2 的整数数组 [index1, index2] 的形式返回这两个整数的下标 index1 和 index2。 * * 你可以假设每个输入 只对应唯一的答案 ,而且你 不可以 重复使用相同的元素。 * * 你所设计的解决方案必须只使用常量级的额外空间。 * * * 示例 1: * * * 输入:numbers = [2,7,11,15], target = 9 * 输出:[1,2] * 解释:2 与 7 之和等于目标数 9 。因此 index1 = 1, index2 = 2 。返回 [1, 2] 。 * * 示例 2: * * * 输入:numbers = [2,3,4], target = 6 * 输出:[1,3] * 解释:2 与 4 之和等于目标数 6 。因此 index1 = 1, index2 = 3 。返回 [1, 3] 。 * * 示例 3: * * * 输入:numbers = [-1,0], target = -1 * 输出:[1,2] * 解释:-1 与 0 之和等于目标数 -1 。因此 index1 = 1, index2 = 2 。返回 [1, 2] 。 * * * * * 提示: * * * 2 <= numbers.length <= 3 * 10^4 * -1000 <= numbers[i] <= 1000 * numbers 按 非递减顺序 排列 * -1000 <= target <= 1000 * 仅存在一个有效答案 * *

* @lc app=leetcode.cn id=318 lang=golang * * [318] 最大单词长度乘积 * * https://leetcode.cn/problems/maximum-product-of-word-lengths/description/ * * algorithms * Medium (73.66%) * Likes: 368 * Dislikes: 0 * Total Accepted: 59.3K * Total Submissions: 80.5K * Testcase Example: '["abcw","baz","foo","bar","xtfn","abcdef"]' * * 给你一个字符串数组 words ,找出并返回 length(words[i]) * length(words[j]) * 的最大值,并且这两个单词不含有公共字母。如果不存在这样的两个单词,返回 0 。 * * * * 示例 1: * * * 输入:words = ["abcw","baz","foo","bar","xtfn","abcdef"] * 输出:16 * 解释:这两个单词为 "abcw", "xtfn"。 * * 示例 2: * * * 输入:words = ["a","ab","abc","d","cd","bcd","abcd"] * 输出:4 * 解释:这两个单词为 "ab", "cd"。 * * 示例 3: * * * 输入:words = ["a","aa","aaa","aaaa"] * 输出:0 * 解释:不存在这样的两个单词。 * * * * * 提示: * * * 2 <= words.length <= 1000 * 1 <= words[i].length <= 1000 * words[i] 仅包含小写字母 * *

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL