当前位置:网站首页>9. lt.491 Longest increasing subsequence
9. lt.491 Longest increasing subsequence
2022-06-09 12:02:00 【Caicai's big data development path】
lt.491. Increasing subsequence
[ Case needs ]

[ Thought analysis ]


[ Code implementation ]
class Solution {
List<List<Integer>> lists = new ArrayList<>();
List<Integer> path = new ArrayList<>();
public List<List<Integer>> findSubsequences(int[] nums) {
backTracking(nums, 0);
return lists;
}
public void backTracking(int[] nums, int startIndex){
//2. The end condition , path There are more than two elements in
if(path.size() > 1){
lists.add(new ArrayList<>(path));
//return;
}
//3. Single layer recursive logic
// How to remove the weight of each layer ?
// for The process of looping is the process of traversing each layer , Every time you go back into for A loop is a walk through each layer
// So we
int[] used = new int[201];
for(int i = startIndex; i < nums.length; i++){
// Carry out weight removal on the same layer
// Two criteria ,
//1. Ascending operation , If path Number that already exists in > The one to be traversed nums[i], Then skip this number
//2. Each layer shall be de weighted , such as [4,7] and [4,7] Although not on the same path , But on the same floor , Need to be heavy
if(!path.isEmpty() && nums[i] < path.get(path.size() - 1) ||
used[nums[i] + 100] == 1) continue;
used[nums[i] + 100] = 1;
path.add(nums[i]);
backTracking(nums, i + 1);
path.remove(path.size() - 1);
}
}
}
lt.240- Search for a two-dimensional matrix ||
[ Case needs ]
[ Thought analysis ]
[ Code implementation ]
lt.240- Search for a two-dimensional matrix ||
[ Case needs ]
[ Thought analysis ]
[ Code implementation ]
边栏推荐
- PMP项目管理知识体系
- 7.<tag-回溯和子集问题>lt.70.子集 + lt.90.子集 II
- Iphone5s display disabled solution
- Suggested collection: concept, classification, value of data standards and analysis of six implementation steps
- tag回溯-刷题预备知识-1. 回溯法模板, + lt.46. 全排列
- 08 | middle stage landing step 3: middle stage planning and design
- 小米智能摄像机云台Pro如何插入视频监控存储卡
- 【堆排|快排】Top-k问题
- 2021年下半年系统集成项目管理工程师案例分析真题及答案解析
- 06 | 中台落地第一步:企业战略分解及现状调研(Discovery)
猜你喜欢

6.两两交换链表中的节点

Win10 your organization has turned off automatic update. How to solve the problem?
![[patch analysis] cve-2016-8610: patch analysis of](/img/cb/77578a38c2c907c6ee83ac0f70df88.png)
[patch analysis] cve-2016-8610: patch analysis of "SSL death alert" vulnerability leading to denial of service
![[data center stage] 00 opening words data center stage, is it a trap? Or the golden key?](/img/19/256cdcf783986d1012ddc75c8b2c31.png)
[data center stage] 00 opening words data center stage, is it a trap? Or the golden key?

05 | D4模型:中台规划建设方法论概述

03 | 中台定义:当我们谈中台时到底在谈些什么?

Windows远程时提示CredSSP加密数据库修正

06 | the first step of China Taiwan landing: enterprise strategy decomposition and current situation research (Discovery)

Win11正式发布新功能

3.<tag-回溯和组合及其剪枝>lt.17. 电话号码的字母组合
随机推荐
内核中_init,_exit中的作用
AGCO AI frontier promotion (6.9)
xxl-job 使用初体验
8K resolution 7680*4320
7.移除元素
H3C Certified Wireless senior engineer
tag回溯-刷题预备知识-1. 回溯法模板, + lt.46. 全排列
流畅看1080p、2k、4k视频需要多大带宽?
IPv6 address assignment
Win11 officially released new features
Security evaluation of commercial password application
传入base64集合,导出大图片
如何通过鸿蒙生态赚钱?
Go zero micro Service Practice Series (II. Service splitting)
LR11安装报错:此计算机上缺少vc2005_sp1_with_atl_fix_redist,请安装所有缺少的必要组件,然后重新运行此安装。
[data center stage] 00 opening words data center stage, is it a trap? Or the golden key?
Conversion function between string and numeric value in C language
Iphone5s display disabled solution
6.<tag-回溯和切割问题>lt.131.分割回文串
11.<tag-二叉树和BST基础>lt.501. 二叉搜索树中的众数