leetcode removing string stars

lovesickness,twilight-and-stars

相思,黄昏和星星 Created: 2023-06-27T09:26+08:00 Published: 2023-07-15T19:29+08:00 Categories: Fragment Tags: Diary [toc] # 成长中忽然意识到的事 昨天拜访亲戚,想起自己在某一天忽然意识到,所有 ......

java—运行时常量池(Runtime Constant Pool)、常量池(Constant Pool)、字符串常量池(String Constant Pool)

最近在看常量池相关的东西的时候,会被这几个常量池给弄的晕乎乎的 查阅了《深入理解java虚拟机》总结如下: 一、常量池共有三类: ’运行时常量池(Runtime Constant Pool) 常量池(Constant Pool):也是常说的class文件常量池(class constant pool ......
常量 Constant Pool 字符串 字符

String

String str1= "abc"; String str2= new String("abc"); String str3= str2.intern(); System.out.println(str1==str2); System.out.println(str2==str3); System ......
String

leetcode刷题记录Java

``` 难度等级:简单 给你两个字符串 word1 和 word2 。请你从 word1 开始,通过交替添加字母来合并字符串。 如果一个字符串比另一个字符串长,就将多出来的字母追加到合并后字符串的末尾。 返回 合并后的字符串 。 class Solution { public String merg ......
leetcode Java

leetcode刷题记录(C语言)

``` 给你两个字符串 word1 和 word2 。请你从 word1 开始,通过交替添加字母来合并字符串。 如果一个字符串比另一个字符串长,就将多出来的字母追加到合并后字符串的末尾。 返回 合并后的字符串 。 输入:word1 = "abc", word2 = "pqr" 输出:"apbqcr" ......
leetcode 语言

go strings.Builder

字符串拼接和strings.Buffer缺点 Go里面的字符串是常量,对字符串的修改会重新申请内存地址。虽然bytes.Buffer避免了字符串修改过程中的内存申请,但是最后从[]byte转成字符串时会重新内存申请。从Go 1.10开始,提供了性能更好的方法strings.Builder,与byte ......
Builder strings go

Leetcode283. 移动零

``` class Solution { public: void moveZeroes(vector& nums) { if(nums.empty()) return; int n=nums.size(); int idx=n-1; while(idx>=0&&nums[idx]==0) idx- ......
Leetcode 283

Leetcode240.搜索二维矩阵II

``` class Solution { public: bool searchMatrix(vector>& matrix, int target) { if(matrix.empty()||matrix[0].empty()) return false; int n=matrix.size(), ......
矩阵 Leetcode 240

[LeetCode] 1218. Longest Arithmetic Subsequence of Given Difference

Given an integer array arr and an integer difference, return the length of the longest subsequence in arr which is an arithmetic sequence such that th ......

LeetCode 354. Russian Doll Envelopes 排序+LIS

You are given a 2D array of integers `envelopes` where `envelopes[i] = [wi, hi]` represents the width and the height of an envelope. One envelope can ......
Envelopes LeetCode Russian Doll 354

LeetCode 519. Random Flip Matrix 哈希Map

There is an `m x n` binary grid matrix with all the values set 0 initially. Design an algorithm to randomly pick an index `(i, j)` where `matrix[i][j] ......
LeetCode Random Matrix Flip 519

java--String类的常用方法

一、获取 1、length() 获取字符串长度 String str = "ahcckmvevawe"; System.out.println(str.length()); //输出12 2、charAt(int index) 返回下标对应的字符 String str = "ahcckmvevawe ......
常用 方法 String java

什么是STAR法则?什么是PDCA?这两个法则有什么区别和联系?

STAR法则是一种用于回答面试问题或撰写工作经历的方法。它是指Situation(情境)、Task(任务)、Action(行动)和Result(结果)的缩写。按照STAR法则,回答问题或描述经历时,首先阐述面临的情境或任务,然后描述所采取的具体行动,并最后强调所取得的结果。 PDCA是Plan-Do ......
法则 两个 STAR PDCA

LeetCode 239. 滑动窗口最大值

``` class Solution { public: vector maxSlidingWindow(vector& nums, int k) { deque q; vector res; for(int i=0;i=k) q.pop_front(); //插入新元素 while(q.size( ......
最大值 LeetCode 239

gcc5 std::string的变化

自从GCC-5.1开始,std::string引入了遵从C++11标准的新实现,默认使用SSO(small string optimization)特性,禁用了写时复制(COW)引用计数机制,这也带来了与旧版本std::string的ABI兼容性问题。 参考: http://www.pandadem ......
string gcc5 gcc std

LeetCode 剑指 Offer 13. 机器人的运动范围

#题目链接:[LeetCode 剑指 Offer 13. 机器人的运动范围](https://leetcode.cn/problems/ji-qi-ren-de-yun-dong-fan-wei-lcof/) ##题意: **地上有一个m行n列的方格,从坐标 [0,0] 到坐标 [m-1,n-1] ......
机器人 LeetCode 范围 机器 Offer

字符串 String 之 StringBuffer

@Test public void f() { String s1 = "a"; String tmp = s1; s1 += "b"; System. out. println(tmp); //a System. out. println(s1) ; //ab } @Test public voi ......
字符串 StringBuffer 字符 String

leetcode day2 977 209 59

[toc] #977 ##暴力法 直接数组中每个元素平方后用sort进行排序 ##双指针法 数组是有序的,平方后最大的元素存在于nums的两端,所以就定义两个指向两端的指针, 然后比较两端绝对值的大小,大的加入新定义的ans数组,并且指针向内移动 ``` vector ans (nums.size( ......
leetcode day2 day 977 209

MyBatis返回resultType=Map的用法, 返回List<Map<String,String>>

<select id="statOnlineAndNotlineNumber" resultType="java.util.Map" parameterType="java.lang.String" > SELECTonline_state as state,COUNT(online_state) ......
String resultType Map MyBatis List

字符串 String 之 equals( )方法

/* String类提供了equals()方法,比较存储在两个字符串对象的内容是否一致 */ @Test public void f1() { // 创建string对象 String str1 = "hello"; //推荐使用字面量方法 String str2 = new String(); / ......
字符串 字符 方法 String equals

Leetcode238. 除自身以外数组的乘积

``` class Solution { public: vector productExceptSelf(vector& nums) { vector q; int t=1; for(auto i:nums) { q.push_back(t); t*=i; } t=1; for(int i=num ......
乘积 数组 Leetcode 238

LeetCode -- 787. K 站中转内最便宜的航班

有边数限制的最短路 1、动态规划 f[i][j]表示恰好通过i次,从起点到大j这个点的最短路径。 class Solution { private: static constexpr int INF = 10000 * 101 + 1; public: int findCheapestPrice(i ......
航班 LeetCode 787

[LeetCode] 2542. Maximum Subsequence Score

You are given two 0-indexed integer arrays nums1 and nums2 of equal length n and a positive integer k. You must choose a subsequence of indices from n ......
Subsequence LeetCode Maximum Score 2542

leetcode-20. 有效的括号

https://leetcode.cn/problems/valid-parentheses/ 20. 有效的括号 给定一个只包括 '(',')','{','}','[',']' 的字符串 s ,判断字符串是否有效。 有效字符串需满足: 左括号必须用相同类型的右括号闭合。 左括号必须以正确的顺序闭合 ......
括号 leetcode 20

[LeetCode] 931. Minimum Falling Path Sum

Given an n x n array of integers matrix, return the minimum sum of any falling path through matrix. A falling path starts at any element in the first ......
LeetCode Falling Minimum Path 931

js string 转换为十六进制转义序列

function convertToHexEscape(str) { let hexEscape = ""; for (let i = 0; i < str.length; i++) { const charCode = str.charCodeAt(i); const hexValue = cha ......
转义 十六进制 序列 string js

字符串转list以及list调remove方法报错

String str = scanner.nextLine(); String[] arr = str.split(""); List<String> list = new ArrayList<>(Arrays.asList(arr)); 注意:使用Array.aslList时转出来的list是没有 ......
list 字符串 字符 方法 remove

LeetCode —— 子串

560. 和为 K 的子数组(哈希表) 官方题解:https://leetcode.cn/problems/subarray-sum-equals-k/solution/he-wei-kde-zi-shu-zu-by-leetcode-solution/ 假设 left 到 right 下标的子数组 ......
LeetCode

LeetCode —— 哈希表

128. 最长连续序列 不要求在位置数组中是连续的 输入:nums = [100,4,200,1,3,2] 输出:4 解释:最长数字连续序列是 [1, 2, 3, 4]。它的长度为 4。 两种最朴素的解法之一: 先排序,从前往后找最长连续上升序列即可。该思路简单有效,但是复杂度已经至少有 O(nlo ......
LeetCode

Leetcode - 动态规划总结(必看!!!)

一、labuladong动态规划模板思路 wiki:https://labuladong.gitee.io/algo/di-ling-zh-bfe1b/dong-tai-g-1e688/ 题目: 动态规划模板思路: 二、我自己如何理解【状态】【选择】 以714题目《最佳时机去买卖股票+手续费》为例子 ......
Leetcode 动态