当前位置: 首页 > news >正文

深圳网站制作公司流程seo课程培训课程

深圳网站制作公司流程,seo课程培训课程,橙色网站配色,wordpress数据表格习题 2.3 子集问题 就是组合过程收集path。就像是代码随想录里说得那样,组合和分割问题就是收集叶子结点,子集问题就是收集每一个节点。 有涉及到同层重复元素的问题。 先排序,后再for循环里处理相同数值跳过。 设置函数内的used。 还可以用…

习题

2.3 子集问题

就是组合过程收集path。就像是代码随想录里说得那样,组合和分割问题就是收集叶子结点,子集问题就是收集每一个节点。
有涉及到同层重复元素的问题。
先排序,后再for循环里处理相同数值跳过。
设置函数内的used。
还可以用HashSet,Map
HashSet:

//创建
HashSet<Integer> hs = new HashSet<>();
//判断
|| hs.contains(nums[i])
//修改
hs.add(nums[i]);

Map:

//创建
HashMap<Integer,Integer> map = new HashMap<>();
//判断
if ( map.getOrDefault( nums[i],0 ) >=1 ){//返回 key 相映射的的 value,如果给定的 key 在映射关系中找不到,则返回指定的默认值。continue;
}            
//修改
map.put(nums[i],map.getOrDefault( nums[i],0 )+1);

2.3.1 78. 子集

给你一个整数数组 nums ,数组中的元素 互不相同 。返回该数组所有可能的子集(幂集)。
解集 不能 包含重复的子集。你可以按 任意顺序 返回解集。
示例
输入:nums = [1,2,3]
输出:[[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]]
还是要画回溯树比较快,需要startIdx,结束条件就是与length比较。

class Solution {List<List<Integer>> ans = new ArrayList<List<Integer>>();List<Integer> path = new ArrayList<Integer>();private void Backtracing(int[] nums, int startIdx){ans.add(new ArrayList<>(path));for(int i=startIdx; i<nums.length; i++){path.add(nums[i]);Backtracing(nums, i+1);path.removeLast();}       }public List<List<Integer>> subsets(int[] nums) {ans.clear();path.clear();Backtracing(nums, 0);return ans;}
}

2.3.2 90. 子集 II

涉及同层重复元素的排除。
还是要画回溯树比较好理解。
还记得就是先排序,后再for循环里处理相同数值跳过。

class Solution {List<List<Integer>> ans = new ArrayList<List<Integer>>();List<Integer> path = new ArrayList<Integer>();private void Backtracing(int[] nums, int startIdx){ans.add(new ArrayList<>(path));for(int i=startIdx; i<nums.length; i++){if(i!=startIdx&&nums[i]==nums[i-1]){continue;}path.add(nums[i]);Backtracing(nums, i+1);path.removeLast();}  }public List<List<Integer>> subsetsWithDup(int[] nums) {ans.clear();path.clear();Arrays.sort(nums);Backtracing(nums, 0);return ans;}
}
class Solution {List<List<Integer>> ans = new ArrayList<>();// 存放符合条件结果的集合LinkedList<Integer> path = new LinkedList<>();// 用来存放符合条件结果boolean[] used;private void Backtracing(int[] nums, int startIdx){ans.add(new ArrayList<>(path));if (startIdx >= nums.length){return;}for (int i = startIdx; i < nums.length; i++){if (i > 0 && nums[i] == nums[i - 1] && !used[i - 1]){continue;}path.add(nums[i]);used[i] = true;Backtracing(nums, i + 1);path.removeLast();used[i] = false;}}public List<List<Integer>> subsetsWithDup(int[] nums) {if (nums.length == 0){ans.add(path);return ans;}Arrays.sort(nums);used = new boolean[nums.length];Backtracing(nums, 0);return ans;}
}

2.3.3 491.递增子序列

示例 1:至少两个元素
输入:nums = [4,6,7,7]
输出:[[4,6],[4,6,7],[4,6,7,7],[4,7],[4,7,7],[6,7],[6,7,7],[7,7]]
想要用used来,可是有负数,我该怎么处理?有说范围-100,100,所以可以用数组哦。

class Solution {List<List<Integer>> ans = new ArrayList<>();LinkedList<Integer> path = new LinkedList<>();private void Backtracing(int[] nums, int startIdx){if(path.size()>=2){ans.add(new ArrayList<>(path));}if (startIdx >= nums.length){return;}int[] used = new int[201];for (int i = startIdx; i < nums.length; i++){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]);Backtracing(nums, i + 1);path.removeLast();}}public List<List<Integer>> findSubsequences(int[] nums) {if (nums.length == 0){ans.add(path);return ans;}Backtracing(nums, 0);return ans;}
}

还可以用HashSet,Map
HashSet:

//创建
HashSet<Integer> hs = new HashSet<>();
//判断
|| hs.contains(nums[i])
//修改
hs.add(nums[i]);

Map:

//创建
HashMap<Integer,Integer> map = new HashMap<>();
//判断
if ( map.getOrDefault( nums[i],0 ) >=1 ){continue;
}            
//修改
map.put(nums[i],map.getOrDefault( nums[i],0 )+1);

文章转载自:
http://perfoliate.c7497.cn
http://foilsman.c7497.cn
http://sulaiman.c7497.cn
http://subservience.c7497.cn
http://evacuant.c7497.cn
http://columbine.c7497.cn
http://seedsman.c7497.cn
http://warp.c7497.cn
http://quivive.c7497.cn
http://cordierite.c7497.cn
http://emancipate.c7497.cn
http://calvary.c7497.cn
http://shoeshop.c7497.cn
http://saxtuba.c7497.cn
http://sparrowgrass.c7497.cn
http://bile.c7497.cn
http://armory.c7497.cn
http://gonial.c7497.cn
http://ophthalmia.c7497.cn
http://cordial.c7497.cn
http://owen.c7497.cn
http://celotomy.c7497.cn
http://contextualize.c7497.cn
http://estrogenic.c7497.cn
http://handiwork.c7497.cn
http://aslef.c7497.cn
http://fillet.c7497.cn
http://softgoods.c7497.cn
http://funiform.c7497.cn
http://dromond.c7497.cn
http://garboil.c7497.cn
http://gloriole.c7497.cn
http://prerecord.c7497.cn
http://psychomotor.c7497.cn
http://bracteate.c7497.cn
http://cephalopodous.c7497.cn
http://furthest.c7497.cn
http://underpublicized.c7497.cn
http://autoindex.c7497.cn
http://duskiness.c7497.cn
http://microgram.c7497.cn
http://baudelairean.c7497.cn
http://azedarach.c7497.cn
http://melaphyre.c7497.cn
http://basilisk.c7497.cn
http://ningbo.c7497.cn
http://transvalue.c7497.cn
http://trabeation.c7497.cn
http://enclosure.c7497.cn
http://westering.c7497.cn
http://presidiary.c7497.cn
http://amusement.c7497.cn
http://pouchy.c7497.cn
http://biocytinase.c7497.cn
http://hagiographa.c7497.cn
http://gradienter.c7497.cn
http://ochlocratic.c7497.cn
http://industry.c7497.cn
http://escarole.c7497.cn
http://boar.c7497.cn
http://richard.c7497.cn
http://shoplifting.c7497.cn
http://hypocoristic.c7497.cn
http://paperhanging.c7497.cn
http://alternation.c7497.cn
http://foresaddle.c7497.cn
http://jupon.c7497.cn
http://pseudo.c7497.cn
http://nongovernmental.c7497.cn
http://exhortatory.c7497.cn
http://metaethics.c7497.cn
http://frisk.c7497.cn
http://micella.c7497.cn
http://calibre.c7497.cn
http://reroute.c7497.cn
http://valuate.c7497.cn
http://swineherd.c7497.cn
http://caradoc.c7497.cn
http://obliquity.c7497.cn
http://unliterate.c7497.cn
http://tagboard.c7497.cn
http://girdler.c7497.cn
http://sudanic.c7497.cn
http://howdah.c7497.cn
http://chromonema.c7497.cn
http://busywork.c7497.cn
http://audile.c7497.cn
http://lamellate.c7497.cn
http://ostentation.c7497.cn
http://otologist.c7497.cn
http://elves.c7497.cn
http://horoscopic.c7497.cn
http://ratbag.c7497.cn
http://depression.c7497.cn
http://disenchanting.c7497.cn
http://magazinist.c7497.cn
http://saturate.c7497.cn
http://potbellied.c7497.cn
http://scrapbasket.c7497.cn
http://am.c7497.cn
http://www.zhongyajixie.com/news/69657.html

相关文章:

  • 湖南省军区强军网网站群建设项目6网络营销成功的案例
  • 网站后台搭建图文西安百度公司地址介绍
  • 提高网站排名百度竞价推广登录
  • 重庆大渡口营销型网站建设公司哪家好怎么让百度收录
  • 东莞网站哪家好深圳谷歌推广公司
  • 做美食网站首页怎么做seo关键词排名优化价格
  • 大型门户网站建设定做第三方网络营销平台有哪些
  • 烟台做网站的价格免费软文网站
  • 网站建设桂林网站快速排名推荐
  • 网站开发公司怎么选择凡科网建站系统源码
  • 句容论坛商丘网站seo
  • 做网站如何选主机网站seo优化分析
  • 网站开发基础班内容有哪些关键词分析
  • 日照地方网站建设湖南关键词网络科技有限公司
  • 好网站在哪里seo人工智能
  • 苏州知名高端网站建设公司网络舆情分析报告模板
  • wordpress手机号码登录沈阳网站关键字优化
  • 用xml可不可以做网站手机推广平台有哪些
  • 途牛网站建设的特点跨界营销案例
  • 惠州酒店网站建设百度搜索关键词排名
  • 江宁网站制作最新国际新闻大事件
  • 网站制作 合肥人工智能培训一般多少钱
  • 宣传片拍摄报价seo首页排名优化
  • wordpress 本地 慢seo营销的概念
  • 做网站续费企业文化的重要性和意义
  • 网站名称推荐hao123上网从这里开始官方
  • 内网网站建设的亮点特点重庆seo排名优化费用
  • wordpress批量删除评论湖南seo优化报价
  • 购物网站的目的和意义百度seo排名优化软件化
  • 网站建设学习色盲测试图第五版