• 简单的洗牌算法Java加LeetCode刷题

    时间:2024-05-04 16:39:01

    CardDemo类创建 import java.util.ArrayList;import java.util.List;import java.util.Random;import java.util.concurrent.CopyOnWriteArrayList;public class Car...

  • LeetCode_Palindrome Partitioning II

    时间:2024-05-04 12:35:39

    Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning ...

  • [LeetCode] Substring with Concatenation of All Words 串联所有单词的子串

    时间:2024-05-03 23:22:30

    You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a conca...

  • LeetCode 笔记系列13 Jump Game II [去掉不必要的计算]

    时间:2024-05-03 11:18:31

    题目: Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your ma...

  • [LeetCode] 921. Minimum Add to Make Parentheses Valid 使括号有效的最少添加

    时间:2024-05-02 19:29:56

    Given a string `S` of `'('` and `')'` parentheses, we add the minimum number of parentheses ( `'('` or `')'`, and in any positions ) so that the resul...

  • LeetCode 921. 使括号有效的最少添加(Minimum Add to Make Parentheses Valid) 48

    时间:2024-05-02 18:42:06

    921. 使括号有效的最少添加921. Minimum Add to Make Parentheses Valid题目描述给定一个由 '(' 和 ')' 括号组成的字符串 S,我们需要添加最少的括号( '(' 或是 ')',可以在任何位置),以使得到的括号字符串有效。从形式上讲,只有满足下面几点之一...

  • 【LeetCode】921. Minimum Add to Make Parentheses Valid 解题报告(Python & C++)

    时间:2024-05-02 18:39:13

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/目录题目描述题目大意解题方法日期题目地址: https://leetcode.com/problems/minimum-add-to-make-parentheses-valid/题目描述G...

  • [LeetCode] 4 Keys Keyboard 四键的键盘

    时间:2024-05-02 12:33:16

    Imagine you have a special keyboard with the following keys:Key 1: (A): Print one 'A' on screen.Key 2: (Ctrl-A): Select the whole screen.Key 3: (Ctrl-...

  • Golang | Leetcode Golang题解之第59题螺旋矩阵II-题解:

    时间:2024-05-01 19:01:30

    func generateMatrix(n int) [][]int { matrix := make([][]int, n) for i := range matrix { matrix[i] = make([]int, n) } num := 1 l...

  • (LeetCode)用两个栈实现一个队列

    时间:2024-05-01 19:00:42

    LeetCode上面的一道题目。原文例如以下:Implement the following operations of a queue using stacks.push(x) -- Push element x to the back of queue.pop() -- Removes the ...

  • 【算法】【贪心算法】【leetcode】870. 优势洗牌

    时间:2024-05-01 13:46:00

    题目地址:https://leetcode.cn/problems/advantage-shuffle/description/ 题目描述: 给定两个长度相等的数组 nums1 和 nums2,nums1 相对于 nums2 的优势可以用满足 nums1[i] > nums2[i] 的索...

  • LeetCode in Python 74/240. Search a 2D Matrix I/II (搜索二维矩阵I/II)

    时间:2024-04-30 21:56:29

    搜索二维矩阵I其实可以转换为搜索一维数组,原因在于,只要先确定搜索的整数应该在哪一行,即可对该行进行二分查找。 搜索二维矩阵II中矩阵元素排列方式与I不同,但思想大致相同。 目录 LeetCode in Python 74. LeetCode in Python 240.  LeetCode in ...

  • leetcode-686-Repeated String Match(重复多少次A能够找到B)

    时间:2024-04-30 19:28:41

    题目描述:Given two strings A and B, find the minimum number of times A has to be repeated such that B is a substring of it. If no such solution, return -1...

  • LeetCode154.寻找旋转排序数组中的最小值 II

    时间:2024-04-30 13:23:46

    154.寻找旋转排序数组中的最小值 II描述假设按照升序排序的数组在预先未知的某个点上进行了旋转。( 例如,数组 [0,1,2,4,5,6,7] 可能变为 [4,5,6,7,0,1,2] )。请找出其中最小的元素。注意数组中可能存在重复的元素。示例示例 1:输入: [1,3,5]输出: 1示例 2:...

  • Java for LeetCode 145 Binary Tree Postorder Traversal

    时间:2024-04-30 12:07:23

    Given a binary tree, return the postorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [3,2,1...

  • Leetcode: Mini Parser

    时间:2024-04-29 18:22:36

    Given a nested list of integers represented as a string, implement a parser to deserialize it.Each element is either an integer, or a list -- whose el...

  • LeetCode 刷题 -- Day 5

    时间:2024-04-29 17:20:45

    今日题目 题目难度备注232. 用栈实现队列 简单225. 用队列实现栈简单20. 有效的括号 简单1047. 删除字符串中的所有相邻重复项简单有所得:string也为栈150. 逆波兰表达式求值中等239. 滑动窗口最大值 困难通过模拟优化代码347. 前 K 个高频元素中等⭐⭐⭐ 栈和队列篇...

  • Binary Tree Paths leetcode

    时间:2024-04-29 16:40:42

    Given a binary tree, return all root-to-leaf paths.For example, given the following binary tree: 1 / \2 3 \ 5All root-to-leaf paths are:["1-&...

  • 【Leetcode每日一题】 动态规划 - 简单多状态 dp 问题 - 打家劫舍 II(难度⭐⭐)(67)

    时间:2024-04-29 11:37:32

    1. 题目解析 题目链接:213. 打家劫舍 II 这个问题的理解其实相当简单,只需看一下示例,基本就能明白其含义了。 2.算法原理 这个问题是经典的“打家劫舍”问题的变种,原问题是在单排房屋中进行偷窃,而这个问题则是在环形排列的房屋中进行。环形排列的特点在于首尾相连,这为我们设计算法带来了新的挑...

  • Leetcode 334. Increasing Triplet Subsequence-Algorithm

    时间:2024-04-29 07:29:52

    Dynamic Programming (DP). Following the increasing length of tuples, scan the array from front to back each time, saving the position of the smallest