码迷,mamicode.com
首页 >  
搜索关键字:leetcode 19    ( 34993个结果
LeetCode1
解法1 class Solution: def twoSum(self, nums: List[int], target: int) -> List[int]: dit = {} for i in range(len(nums)): other = target - nums[i] if other ...
分类:其他好文   时间:2021-04-06 14:26:04    阅读次数:0
[LeetCode] 781. Rabbits in Forest
In a forest, each rabbit has some color. Some subset of rabbits (possibly all of them) tell you how many other rabbits have the same color as them. Th ...
分类:其他好文   时间:2021-04-06 14:17:51    阅读次数:0
31. 下一个排列 + 双指针 + 思维
31. 下一个排列 LeetCode_31 题目描述 题解分析 代码实现 class Solution { public void nextPermutation(int[] nums) { int i = nums.length - 2; while(i >= 0 && nums[i] >= nu ...
分类:其他好文   时间:2021-04-06 14:03:32    阅读次数:0
LeetCode——412. Fizz Buzz
题目描述 题干: 写一个程序,输出从 1 到 n 数字的字符串表示。 1. 如果 n 是3的倍数,输出“Fizz”; 2. 如果 n 是5的倍数,输出“Buzz”; 3.如果 n 同时是3和5的倍数,输出 “FizzBuzz”。 实例: n = 15, 返回: [ "1", "2", "Fizz", ...
分类:其他好文   时间:2021-04-05 12:31:23    阅读次数:0
LeetCode—数组中数字出现的次数
今天刷力扣遇到了这样的问题: 一个整型数组 nums 里除两个数字之外,其他数字都出现了两次。请写程序找出这两个只出现一次的数字。要求时间复杂度是O(n),空间复杂度是O(1)。 之前没有遇到过类似的题型,看到之后很懵,看了题解才知道要用到分组异或的方式进行分组。题解又看了十分钟才终于理解解法的含义 ...
分类:编程语言   时间:2021-04-05 12:23:52    阅读次数:0
Leetcode 524. Longest Word in Dictionary through Deleting
Description: Given a string s and a string array dictionary, return the longest string in the dictionary that can be formed by deleting some of the gi ...
分类:其他好文   时间:2021-04-05 12:21:20    阅读次数:0
LeetCode 206题 反转链表 (21.4.2)
LeetCode 206题 反转链表 题目描述: 反转一个单链表。 涉及内容:链表 示例: 输入: 1->2->3->4->5->NULL 输出: 5->4->3->2->1->NULL 思路 : 提交结果: 完整代码: # Definition for singly-linked list. # ...
分类:其他好文   时间:2021-04-05 11:57:29    阅读次数:0
LeetCode: 二叉树的遍历
二叉树的遍历 前序遍历 LeetCode.144. 二叉树的前序遍历 二叉树的前序/中序/后序遍历的非递归描述一般适合用深度优先搜索 (DFS, depth-first search), 并使用栈的数据结构. 版本1 递归 from typing import List class Node: de ...
分类:其他好文   时间:2021-04-05 11:47:20    阅读次数:0
LeetCode: 回溯法
回溯法 全排列 LeetCode.46. 全排列 给定一个没有重复数字的序列, 返回其所有可能的全排列. 示例: 输入: [1,2,3] 输出: [ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1] ] from typing import L ...
分类:其他好文   时间:2021-04-05 11:44:36    阅读次数:0
【Leetcode】排序相关
【Leetcode-215】 一、题目:数组中的第k大元素 在未排序的数组中找到第 k 个最大的元素。请注意,你需要找的是数组排序后的第 k 个最大的元素,而不是第 k 个不同的元素。 二、代码: def findKthLargest(self, nums: List[int], k: int) - ...
分类:编程语言   时间:2021-04-02 13:24:48    阅读次数:0
34993条   上一页 1 ... 23 24 25 26 27 ... 3500 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!