ICode9

精准搜索请尝试: 精确搜索
  • LeetCode刷题7-用连续自然数之和来表达整数2022-08-06 13:00:08

    package com.example.demo.leetcode.case202208; import java.util.Arrays; import java.util.List; import java.util.Scanner; import java.util.stream.Collectors; /** * 功能描述 * * @author ASUS * @version 1.0 * @Date 2022/8/6 */ public class Main2022080601

  • LeetCode刷题4-字符串加密2022-08-05 02:01:40

    package com.example.demo.leetcode.case202208; import java.util.*; /** * 功能描述 * * @author ASUS * @version 1.0 * @Date 2022/8/4 */ public class Main2022080401 { /* 有一种技巧可以对数据进行加密,它使用一个单词作为它的密匙。下面是它的工作原理:首先

  • LeetCode刷题5-玩牌高手2022-08-05 02:01:15

    package com.example.demo.leetcode.case202208; import java.util.LinkedList; import java.util.Scanner; /** * 功能描述 * * @author ASUS * @version 1.0 * @Date 2022/8/5 */ public class Main2022080501 { /* 玩牌高手 题目描述 给定一个长度为n

  • [LeetCode 338] 比特位计数2022-08-04 19:02:25

    比特位计数 LeetCode 338 给你一个整数 n ,对于 0 <= i <= n 中的每个 i ,计算其二进制表示中 1 的个数 ,返回一个长度为 n + 1 的数组 ans 作为答案 O(nlogn) 解法 顺序计算 n 个数二进制表示中的 1 的个数, 对于数字 i, 依次与 \(2^k (2^k \le i)\) 作与操作, 若结果为 1 则计数

  • LeetCode 572 Subtree of Another Tree2022-08-04 04:31:06

    Given the roots of two binary trees root and subRoot, return true if there is a subtree of root with the same structure and node values of subRoot and false otherwise. A subtree of a binary tree tree is a tree that consists of a node in tree and all of th

  • LEETCODE-1471-数组中的k个最强值2022-08-03 12:32:16

    题目参考:https://leetcode.cn/problems/the-k-strongest-values-in-an-array/ 题解参考:https://leetcode.cn/problems/the-k-strongest-values-in-an-array/solution/8402-7544-by-bobby996/ 我的题解 class Solution { public int[] getStrongest(int[] arr, int k) {

  • LeetCode 239 Sliding Window Maximum 单调队列 [Hard]2022-08-03 02:31:06

    You are given an array of integers nums, there is a sliding window of size \(k\) which is moving from the very left of the array to the very right. You can only see the \(k\) numbers in the window. Each time the sliding window moves right by one posit

  • leetcode 504. Base 7 七进制数 (简单)2022-08-02 13:04:08

    一、题目大意 https://leetcode.cn/problems/base-7 给定一个整数 num,将其转化为 7 进制,并以字符串形式输出。 示例 1: 输入: num = 100 输出: "202" 示例 2: 输入: num = -7 输出: "-10" 提示: -107 <= num <= 107 二、解题思路 输入一个整数,输出一个字符串,表示其七进制。

  • Leetcode刷题记录之双指针2022-08-01 23:35:09

    167. 两数之和 II - 输入有序数组 题目描述 给你一个下标从 1 开始的整数数组 numbers ,该数组已按 非递减顺序排列 ,请你从数组中找出满足相加之和等于目标数 target 的两个数。如果设这两个数分别是 numbers[index1] 和 numbers[index2] ,则 1 <= index1 < index2 <= numbers.lengt

  • [LeetCode] 853. Car Fleet2022-08-01 15:35:02

    There are n cars going to the same destination along a one-lane road. The destination is target miles away. You are given two integer array position and speed, both of length n, where position[i] is the position of the ith car and speed[i] is th

  • vscode使用leetcode插件并通过cookie登陆美区leetcode2022-08-01 11:03:20

    安装插件 使用cookie登陆 如果选择使用github登陆leetcode.com,似乎会有无法提交和测试的bug,而用cookie登陆就没有这个问题 使用edge获取cookie 使用Firefox获取的cookie有问题,无法正常登陆 右键,选择检查 选择网络 打开leetcode的problem页面 下滑找到cookie那一栏,复制cookie

  • Leetcode 1161 最大层内元素和2022-07-31 12:35:01

    一、题目 给你一个二叉树的根节点 root。设根节点位于二叉树的第1层,而根节点的子节点位于第2层,依此类推。 请返回层内元素之和 最大 的那几层(可能只有一层)的层号,并返回其中 最小 的那个。 示例 1: 输入:root = [1,7,0,7,-8,null,null] 输出:2 解释: 第 1 层各元素之和为 1, 第 2 层

  • LeetCode 815. Bus Routes2022-07-31 10:03:21

    原题链接在这里:https://leetcode.com/problems/bus-routes/ 题目: You are given an array routes representing bus routes where routes[i] is a bus route that the ith bus repeats forever. For example, if routes[0] = [1, 5, 7], this means that the 0th bus tr

  • LeetCode/二分法综合2022-07-30 21:00:13

    1. 寻找两个正序数组的中位数 2. 两数相除 3. 快速幂 4. 搜索旋转排序数组 5. 数组中的逆序对 6. 在排序数组中查找元素的第一个和最后一个位置 class Solution { public: vector<int> searchRange(vector<int>& nums, int target) { return {find(nums,target,true),

  • [LeetCode] 916. Word Subsets2022-07-30 12:31:49

    You are given two string arrays words1 and words2. A string b is a subset of string a if every letter in b occurs in a including multiplicity. For example, "wrr" is a subset of "warrior" but is not a subset of "world". A st

  • Leetcode 125. 验证回文串2022-07-30 11:00:54

    给定一个字符串,验证它是否是回文串,只考虑字母和数字字符,可以忽略字母的大小写。 说明:本题中,我们将空字符串定义为有效的回文串。 示例 1: 输入: "A man, a plan, a canal: Panama" 输出: true 解释:"amanaplanacanalpanama" 是回文串 示例 2: 输入: "race a car" 输出: false 解

  • 2022.7.30 LeetCode AcWing2022-07-30 10:05:13

    LeetCode 建图 + 并查集 + (筛法求质数) 如果暴力的建图,跑dfs最大连通图,建图会成为瓶颈,O(n^2)。 但是考虑到,A、B两数,A、B分别与其非1非自身的因数相连,如果A、B之间联通,那么A、B相互联通的那个点为公因数。可以将时间复杂度从依赖数据量的大小转移到依赖数据按数据范围。 即建图时,遍

  • leetcode-1853. 转换日期格式2022-07-28 18:33:11

        1853. 转换日期格式 https://leetcode.cn/problems/convert-date-format/   SQL: SELECT concat(dayname(day), ', ', monthname(day), ' ', day(day), ', ', year(day)) AS day FROM Days 结果{"headers": ["day"], "va

  • leetcode-dp-2042022-07-28 11:03:10

    import java.util.Arrays; /** * <p>给定整数 <code>n</code> ,返回 <em>所有小于非负整数&nbsp;<code>n</code>&nbsp;的质数的数量</em> 。</p> * * <p>&nbsp;</p> * * <p><strong>示例 1:</strong&g

  • LeetCode面试题 01.08. 零矩阵2022-07-28 09:35:06

    https://leetcode.cn/problems/zero-matrix-lcci/ class Solution { public void setZeroes(int[][] matrix) { int M=matrix.length; //获取二维数组中一维数组的长度 int N=matrix[0].length; int[][] newMat=new int[M][N]; //把

  • leetcode之两数相加2022-07-28 02:31:41

    // 1.两数之和 // set 存每一位被需要的值,作为key , 值为当前位置的 index // 然后继续遍历下一位,判断下一位是否就是已经存起来的被需要的值 // 如果是,则直接返回当时被需要时那一位的索引 及 当前索引 function sum(nums, target) { let map = new Map(); for (let i

  • LeetCode/外观数列2022-07-27 20:32:09

    给定一个正整数 n ,输出外观数列的第 n 项 「外观数列」是一个整数序列,从数字 1 开始,序列中的每一项都是对前一项的描述 1. 递归 判断相邻相等的方法每次只能处理上一个值 等价于每次比较上一个组的末位置与当前组的初始位置 最后一个值要额外处理 class Solution { public:

  • LeetCode/对角线遍历2022-07-27 17:33:07

    给你一个大小为 m x n 的矩阵 mat ,请以对角线遍历的顺序,用一个数组返回这个矩阵中的所有元素 1. 模拟操作 按照对角线扫描的顺序,首先要清楚得遍历m+n-1趟 对于对角线移动操作,往上扫描时横坐标增,纵坐标减,往下扫描时,横坐标减,纵坐标增 每扫描完一趟,横纵坐标有一个变化 向上扫描结束时

  • 2022.7.27 LeetCode2022-07-27 10:02:49

    LeetCode 模拟 + 字符串 题解如下: https://leetcode.cn/problems/fraction-addition-and-subtraction/solution/by-sen-xm-u2ak/ string转int: https://blog.csdn.net/xiong452980729/article/details/61677701 int转string: to_string() 头文件为 #include

  • Leetcode的中等算法题:198. 打家劫舍2022-07-27 04:32:04

    链接:https://leetcode.cn/problems/house-robber/ 方法1 学会了动态规划思路后,我独立想出来的一个方法,缺点是代码不够优雅(dp和nums的序号有错位)。 我的代码 int max(int a,int b){ return a>b?a:b; } int rob(int* nums, int numsSize){ // dp预留出来2个位置.dp[i+2]表示

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有