摘要: 1、和谐数组是指一个数组里元素的最大值和最小值之间的差别 正好是 1 。 现在,给你一个整数数组 nums ,请你在所有可能的子序列中找到最长的和谐子序列的长度。 数组的子序列是一个由数组派生出来的序列,它可以通过删除一些元素或不删除元素、且不改变其余元素的顺序而得到。 【解题思路一】 先将数组排序 阅读全文
posted @ 2021-11-20 22:50 xmubaron 阅读(232) 评论(0) 推荐(0)
摘要: public class test { int i = 1; public static void main(String[] args) { test obj = new test(); // 使用匿名内部类的形式 Runnable runnable = new Runnable() { @Ove 阅读全文
posted @ 2021-11-20 16:31 xmubaron 阅读(44) 评论(0) 推荐(0)
摘要: import java.lang.*; import java.util.*; class LRUCache{ int cap; LinkedHashMap<Integer, Integer> cache = new LinkedHashMap<>(); public LRUCache(int ca 阅读全文
posted @ 2021-11-20 16:27 xmubaron 阅读(60) 评论(0) 推荐(0)
摘要: import java.lang.*; import java.util.*; public class Main{ /* 删除链表中连续和为0的节点 */ static class ListNode{ int value; ListNode next = null; public ListNode 阅读全文
posted @ 2021-11-20 16:05 xmubaron 阅读(49) 评论(0) 推荐(0)
摘要: #include<iostream> #include<vector> using namespace std; const int N = 10010; /* 输入n个整数,输出出现次数大于等于数组长度一半的数。 */ int main(){ int n; vector<int> q; while 阅读全文
posted @ 2021-11-20 15:47 xmubaron 阅读(108) 评论(0) 推荐(0)