• 搜索+剪枝,LeetCode 216. 组合总和 III

    时间:2024-04-24 19:24:37

    目录 一、题目 1、题目描述 2、接口描述 python3 cpp 3、原题链接 二、解题报告 1、思路分析 2、复杂度 3、代码详解 python3 cpp 一、题目 1、题目描述 找出所有相加之和为 n 的 k 个数的组合,且满足下列条件: 只使用数字1到9每个数字 最多使用一次 返回...

  • LeetCode算法题-Number of Lines To Write String(Java实现)

    时间:2024-04-24 17:32:03

    这是悦乐书的第319次更新,第340篇原创01 看题和准备今天介绍的是LeetCode算法题中Easy级别的第188题(顺位题号是806)。我们要将给定字符串S的字母从左到右写成行。每行最大宽度为100个单位,如果写一个字母会导致该行的宽度超过100个单位,则会写入下一行。给出一个数组宽度,一个数组...

  • LeetCode算法题-Subdomain Visit Count(Java实现)

    时间:2024-04-24 17:16:57

    这是悦乐书的第320次更新,第341篇原创01 看题和准备今天介绍的是LeetCode算法题中Easy级别的第189题(顺位题号是811)。像“discuss.leetcode.com”这样的网站域名由各种子域组成。在顶级,我们有“com”,在下一级,我们有“leetcode.com”,在最低级别,...

  • LeetCode算法题-Jewels and Stones(Java实现)

    时间:2024-04-24 17:14:19

    这是悦乐书的第313次更新,第334篇原创01 看题和准备今天介绍的是LeetCode算法题中Easy级别的第182题(顺位题号是771)。字符串J代表珠宝,S代表你拥有的石头。S中的每个字符都是你拥有的一种石头。计算S中有多少石头也是珠宝。J中的字符不会重复出现,J和S中的所有字符都是英文字母。字...

  • LeetCode算法题-Count Primes(Java实现)

    时间:2024-04-24 16:49:42

    这是悦乐书的第190次更新,第193篇原创01 看题和准备今天介绍的是LeetCode算法题中Easy级别的第49题(顺位题号是204)。计算小于非负数n的素数的数量。例如:输入:10输出:4说明:有4个素数小于10,它们是2,3,5,7。本次解题使用的开发工具是eclipse,jdk使用的版本是1...

  • (算法)LeetCode刷题

    时间:2024-04-24 16:48:14

    LeetCode 56 合并区别Given [1,3],[2,6],[8,10],[15,18],return [1,6],[8,10],[15,18].关键就是a[1]>=b[0] 也就是array[i-1][1]>=array[i][0]const merge = array =...

  • 【leetcode】Spiral Matrix(middle)

    时间:2024-04-23 23:18:45

    Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.For example,Given the following matrix:[ [ 1, ...

  • [LeetCode] Top K Frequent Elements 前K个高频元素

    时间:2024-04-23 16:49:13

    Given a non-empty array of integers, return the k most frequent elements.Example 1:Input: nums = [1,1,1,2,2,3], k = 2Output: [1,2]Example 2:Input: num...

  • 【LeetCode每日一题】924. 尽量减少恶意软件的传播(并查集)

    时间:2024-04-22 22:14:24

    class Solution { public int minMalwareSpread(int[][] graph, int[] initial) { int n = graph.length; UnionFind uf = new UnionFind(n);//...

  • 算法打卡day50|单调栈篇01| Leetcode 739. 每日温度、496.下一个更大元素 I

    时间:2024-04-22 16:49:10

    算法题 Leetcode 739. 每日温度 题目链接:739. 每日温度 大佬视频讲解:739. 每日温度视频讲解  个人思路  因为题目所求的是找到一个元素右边第一个比自己大的元素,这是单调栈的经典题目,用栈来记录遍历过的元素 解法 单调栈 单调栈的本质是空间换时间,因为在遍历的过...

  • [LeetCode] 1. Two Sum_Easy

    时间:2024-04-22 14:49:20

    Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exa...

  • 【代码随想录刷题记录】LeetCode704二分查找

    时间:2024-04-22 11:19:23

    读研以后写AI那些玩意写多了,确实需要练练算法,我现在写个二分查找都出现问题,绷不住了,而且过CSP竞赛是毕业条件,没办法,以后一天刷一个题吧,太忙了 1. 左闭右闭 class Solution {public: //左闭右闭 int search(vector<int>&...

  • [LeetCode] Decode Ways [33]

    时间:2024-04-22 09:59:57

    题目A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded ...

  • 【LeetCode热题100】【动态规划】零钱兑换

    时间:2024-04-21 17:28:51

    题目链接:322. 零钱兑换 - 力扣(LeetCode) 要拿硬币凑钱,硬币无限多,就是完全背包问题,定义dp[i]是要凑的钱i的硬币数,对于当前硬币来说,如果选择了这个硬币,要么要凑的硬币数就变成dp[i-coin] class Solution {public: int coinChan...

  • Leetcode 073 Set Matrix Zeroes

    时间:2024-04-21 11:19:32

    Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.click to show follow up.Follow up:Did you use extra space...

  • 【算法刷题day27】Leetcode:39. 组合总和、40. 组合总和 II、131. 分割回文串-Leetcode 39. 组合总和

    时间:2024-04-20 10:03:31

    题目:39. 组合总和解析:代码随想录解析 解题思路 还是回溯三部曲 代码 class Solution { List<List<Integer>> res = new ArrayList<>(); List<Integer> pa...

  • leetcode:LCR 135. 报数.剑指offer打印从1到最大的n位数

    时间:2024-04-20 07:12:05

    实现一个十进制数字报数程序,请按照数字从小到大的顺序返回一个整数数列,该数列从数字 1 开始,到最大的正整数 cnt 位数字结束。 示例 1: 输入:cnt = 2输出:[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,...

  • 【LeetCode 209】Minimum Size Subarray Sum

    时间:2024-04-19 18:36:28

    Given an array of n positive integers and a positive integer s, find the minimal length of a subarray of which the sum ≥ s. If there isn't one, return...

  • 【力扣】55. 跳跃游戏 - 力扣(LeetCode)-复杂度

    时间:2024-04-19 14:24:02

    时间复杂度: o ( n ...

  • LeetCode -- Triangle 路径求最小和( 动态规划问题)

    时间:2024-04-18 18:08:06

    Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the fol...