leetcode anagrams string find

LeetCode -- 870. 优势洗牌

贪心:这种最大化类似于田忌赛马。 每次取出nums1中最小的,和nums2进行比较,如果打得过,就打;打不过就用当前最小的和nums2中最大的换掉 c ++ class Solution { public: vector<int> advantageCount(vector<int>& nums1, ......
LeetCode 优势 870

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

maven打包repackage failed: Unable to find main class

maven打包提示这个问题。 原因:主项目pomxml文件中,不需要<build>打包的配置,只需要在有入口类的模块pom.xml配置好<build> <build> <finalName>${project.artifactId}</finalName> <plugins> <plugin> <g ......
repackage failed Unable maven class

java--String类的常用方法

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

vim E447: cannot find file iostream in path

查看c/c++文件中的头文件,可以使用gf跳转,但是有时会出现Error 447:not found in path1, 命名模式中输入,临时修改:set path=.,/usr/include,,/usr/include/c++/*/2, 修改vimrc增加set path+=.,/usr/inc ......
iostream cannot E447 find file

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

Find命令的7种用法

可以很肯定地说,find 命令是 Linux 后台开发人员必须熟知的操作之一,除非您使用的是 Windows Server。 对于技术面试,它也是一个热门话题。让我们看一道真题: 如果你的 Linux 服务器上有一个名为 logs 的目录,如何删除该目录下最后一次访问时间超过一年的日志文件呢? 这种 ......
命令 Find

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

Union-Find

title: Union-Find date: 2021-05-17 10:55:40 tags: [Algorithm] # Union-Find 算法详解 今天讲讲 Union-Find 算法,也就是常说的并查集算法,主要是解决图论中「动态连通性」问题的。名词很高端,其实特别好理解,等会解释,另 ......
Union-Find Union Find

destoon列表性能优化,关于IN()与FIND_IN_SET

destoon数据达到一定之后列表打开速度就很慢,于是为了解决这个问题,进行以下办法处理。 找到/include/tag.func.php文件,找到这段代码: 原因: 区别: 1、in后面只能跟常量, find_in_set()函数可以使用常量或字段。 2、in是完全匹配,find_in_set() ......
FIND_IN_SET 性能 destoon IN FIND

字符串 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

达梦数据库中使用find_in_set()函数

本文转载自Allyn博客(http://www.allyns.cn):http://www.allyns.cn/info/102?eqid=c1f67a7a0001c94d0000000364619de7 在日常开发过程中,我遇到了这样一个问题,我在使用数据库实现自定义流程的时候,由于审批人可以是多 ......
find_in_set 函数 数据库 数据 find

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