leetcode removing string stars

LeetCode/特别的排列

给你一个下标从 0 开始的整数数组 nums ,它包含 n 个 互不相同 的正整数。如果 nums 的一个排列满足以下条件,我们称它是一个特别的排列: 对于 0 & nums) { int mod = 1e9+7; int m = nums.size(); int memo[m][m f = [&] ......
LeetCode

string类型可以作为lock的锁对象吗

## lock 关键字介绍 lock 关键字是用于在多线程编程中实现同步和互斥访问的关键字。它的作用是确保共享资源在任意时刻只能被一个线程访问,从而避免出现竞态条件(race condition)和数据不一致的问题。 当多个线程同时访问共享资源时,如果没有合适的同步机制,可能会导致数据损坏、结果的不 ......
对象 类型 string lock

做leetcode算法题的一些感受

leetcode题目做了34道了,写下目前的感受,不一定对,需要经常修改内容。 1、代码是怎么写出来的?不是一下子写出来的,是逐步填充,逐步具体的。一句话,写代码也要看到历史和现状,现状不是突然出现的,是有发展历史的。不是从1直接就到10了,而是从1->2->3,逐步递进,最后到10。写代码总要写第 ......
算法 leetcode

Leetcode: Arrays.sort() - comparator

Arrays.sort(points,(o1,o2)->{ if(o1[1] == o2[1]) return 0; if(o1[1] < o2[1]) return -1; return 1; }) 根据dp[1]进行升序排列,O(NlogN) ......
comparator Leetcode Arrays sort

PostgreSQL合并多行数据为一行,string_agg函数

通过id列来聚合belong_user_saved列,应用string_agg函数,只要id一样则把第二列通过逗号连接起来 聚合前: ![img](https://img2023.cnblogs.com/blog/2446184/202306/2446184-20230622202013405-11 ......
PostgreSQL string_agg 函数 一行 数据

LeetCode--矩形走位

59. 螺旋矩阵 II 定义一个总数,是所有格子走完中心的最大数,target = n*n 从 1 开始,每走一步,当前数 +1 ,while(curNum<=target) 就继续走 定义每圈螺旋走位的边界,初始值:left=0; right=n-1; top=0; bottom=n-1; 1、在 ......
矩形 LeetCode

PostgreSql的聚合函数--string_agg

## [聚合函数](https://so.csdn.net/so/search?q=聚合函数&spm=1001.2101.3001.7020) 顾名思义,聚合函数就是类似于min(),max(),sum()等函数,当然这些都是SQL标准的函数,应该都是比较熟悉,也比较常见。这边不对这些常见的函数进行 ......
PostgreSql string_agg 函数 string agg

leetcode 338. 比特位计数

#### [338. 比特位计数](https://leetcode.cn/problems/counting-bits/) 难度简单 1216 给你一个整数 `n` ,对于 `0 0 1 --> 1 2 --> 10 **示例 2:** **输入:**n = 5 **输出:**[0,1,1,2,1 ......
leetcode 338

leetcode 283. 移动零

#### [283. 移动零](https://leetcode.cn/problems/move-zeroes/) 难度简单 给定一个数组 `nums`,编写一个函数将所有 `0` 移动到数组的末尾,同时保持非零元素的相对顺序。 **请注意** ,必须在不复制数组的情况下原地对数组进行操作。 ** ......
leetcode 283

pwsh string cmd

compose multiple variables into a command line, then execute it. ```ps1 $dest="a:\des" $source="b:\src" $cmdlink="cmd" $cmdPart1="/c", "mklink", "/j" ......
string pwsh cmd

[LeetCode] 面试题 16.19. 水域大小

你有一个用于表示一片土地的整数矩阵land,该矩阵中每个点的值代表对应地点的海拔高度。若值为0则表示水域。由垂直、水平或对角连接的水域为池塘。池塘的大小是指相连接的水域的个数。编写一个方法来计算矩阵中所有池塘的大小,返回值需要从小到大排序。 示例: 输入:[ [0,2,1,0], [0,1,0,1] ......
水域 LeetCode 大小 16 19

将Double类型转换为String类型

在Java中将String转换为Double 使用Double.toString()方法: double num = 3.14159; String str = Double.toString(num); 使用String.valueOf()方法: double num = 3.14159; Str ......
类型 Double String

将Double类型转换为String类型

在Java中将String转换为Double 使用Double.toString()方法: double num = 3.14159; String str = Double.toString(num); 使用String.valueOf()方法: double num = 3.14159; Str ......
类型 Double String

[Leetcode] 0014. 最长公共前缀

# [14. 最长公共前缀](https://leetcode.cn/problems/longest-common-prefix) 点击上方,跳转至Leetcode ## 题目描述 编写一个函数来查找字符串数组中的最长公共前缀。 如果不存在公共前缀,返回空字符串 ""。 示例 1: 输入:strs ......
前缀 Leetcode 0014

[Leetcode] 0020. 有效的括号

# [20. 有效的括号](https://leetcode.cn/problems/valid-parentheses) 点击上方,跳转至leetcode ## 题目描述 给定一个只包括 '(',')','{','}','[',']' 的字符串 s ,判断字符串是否有效。 有效字符串需满足: 左括 ......
括号 Leetcode 0020

[Leetcode] 0009. 回文数

# [9. 回文数](https://leetcode.cn/problems/palindrome-number) 点击上方,跳转至Leetcode ## 题目描述 给你一个整数 x ,如果 x 是一个回文整数,返回 true ;否则,返回 false 。 回文数是指正序(从左向右)和倒序(从右向 ......
回文 Leetcode 0009

[Leetcode] 0013. 罗马数字转整数

# [13. 罗马数字转整数](https://leetcode.cn/problems/roman-to-integer) 点击上方,跳转至leetcode ## 题目描述 罗马数字包含以下七种字符: I, V, X, L,C,D 和 M。 字符 数值 I 1 V 5 X 10 L 50 C 10 ......
整数 Leetcode 数字 0013

[Leetcode] 0728. 自除数

# [728. 自除数](https://leetcode.cn/problems/self-dividing-numbers) 点击上方,跳转至leetcode ## 题目描述 自除数 是指可以被它包含的每一位数整除的数。 例如,128 是一个 自除数 ,因为 128 % 1 == 0,128 % ......
除数 Leetcode 0728

[Leetcode] 0733. 图像渲染

# [733. 图像渲染](https://leetcode.cn/problems/flood-fill) 点击上方,跳转至leetcode ## 题目描述 有一幅以 m x n 的二维整数数组表示的图画 image ,其中 image[i][j] 表示该图画的像素值大小。 你也被给予三个整数 s ......
Leetcode 图像 0733

[Leetcode] 0724. 寻找数组的中心下标

# [724. 寻找数组的中心下标](https://leetcode.cn/problems/find-pivot-index) 点击上方,跳转至leetcode ## 题目描述 给你一个整数数组 nums ,请计算数组的 中心下标 。 数组 中心下标 是数组的一个下标,其左侧所有元素相加的和等于 ......
下标 数组 Leetcode 0724

[Leetcode] 0709. 转换成小写字母

# [709. 转换成小写字母](https://leetcode.cn/problems/to-lower-case) 点击上方跳转至Leetcode ## 题目描述 给你一个字符串 s ,将该字符串中的大写字母转换成相同的小写字母,返回新的字符串。 示例 1: 输入:s = "Hello" 输出 ......
小写 字母 Leetcode 0709

[Leetcode] 0717. 1 比特与 2 比特字符

# [717. 1 比特与 2 比特字符](https://leetcode.cn/problems/1-bit-and-2-bit-characters) 点击上方,跳转至leetcode ## 题目描述 有两种特殊字符: 第一种字符可以用一比特 0 表示 第二种字符可以用两比特(10 或 11) ......
字符 Leetcode 0717

[Leetcode] 0706. 设计哈希映射

# [706. 设计哈希映射](https://leetcode.cn/problems/design-hashmap) 点击跳转至leetcode ## 题目描述 不使用任何内建的哈希表库设计一个哈希映射(HashMap)。 实现 MyHashMap 类: MyHashMap() 用空映射初始化对 ......
Leetcode 0706

Remove Duplicates from Sorted List

Given the head of a sorted linked list, delete all duplicates such that each element appears only once. Return the linked list sorted as well. **Examp ......
Duplicates Remove Sorted List from

Java中的String、StringBuilder和StringBuffer

### String #### String为什么不可变?有什么好处? ![image](https://img2023.cnblogs.com/blog/1950787/202306/1950787-20230620175305920-629279762.png) 在Java中的String源码中 ......
StringBuilder StringBuffer String Java

(Leetcode)将数组按照绝对值大小从大到小排序

【少说多做,少想多做】 ```java nums = IntStream.of(nums). boxed(). sorted((o1,o2)->Math.abs(o2)-Math.abs(o1)) .mapToInt(Integer::intValue).toArray(); ``` + IntSt ......
绝对值 数组 Leetcode 大小

[LeetCode] 2090. K Radius Subarray Averages

You are given a 0-indexed array nums of n integers, and an integer k. The k-radius average for a subarray of nums centered at some index i with the ra ......
LeetCode Averages Subarray Radius 2090

每日一题力扣 1262 https://leetcode.cn/problems/greatest-sum-divisible-by-three/

、 题解 这道题目核心就算是要知道如果x%3=2的话,应该要去拿%3=1的数字,这样子才能满足%3=0 贪心 sum不够%3的时候,就减去余数为1的或者余数为2的 需要注意 两个余数为1会变成余数为2的,所以可能减去2个余数为1 核心代码如下 public int maxSumDivThreeOth ......

[LeetCode] 1262. Greatest Sum Divisible by Three

Given an integer array nums, return the maximum possible sum of elements of the array such that it is divisible by three. Example 1: Input: nums = [3, ......
Divisible LeetCode Greatest Three 1262