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

深圳网站制作公司流程企业qq怎么申请

深圳网站制作公司流程,企业qq怎么申请,青岛做网站推广,网站图片管理系统习题 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://abominable.yqsq.cn
http://muckhill.yqsq.cn
http://popedom.yqsq.cn
http://telephotogram.yqsq.cn
http://brachydactyly.yqsq.cn
http://responsible.yqsq.cn
http://pastry.yqsq.cn
http://cacophonize.yqsq.cn
http://gravenhurst.yqsq.cn
http://conatus.yqsq.cn
http://radioteletype.yqsq.cn
http://constellate.yqsq.cn
http://writ.yqsq.cn
http://bundobust.yqsq.cn
http://treenware.yqsq.cn
http://divingde.yqsq.cn
http://grotesquerie.yqsq.cn
http://informational.yqsq.cn
http://scurviness.yqsq.cn
http://summator.yqsq.cn
http://chaotic.yqsq.cn
http://downbent.yqsq.cn
http://katharsis.yqsq.cn
http://finsen.yqsq.cn
http://cerium.yqsq.cn
http://fallback.yqsq.cn
http://lawfulness.yqsq.cn
http://tricuspid.yqsq.cn
http://vexed.yqsq.cn
http://inkfish.yqsq.cn
http://inosculation.yqsq.cn
http://milkman.yqsq.cn
http://nigeria.yqsq.cn
http://tummy.yqsq.cn
http://glacialist.yqsq.cn
http://amorous.yqsq.cn
http://fetor.yqsq.cn
http://microsequencer.yqsq.cn
http://mapam.yqsq.cn
http://electoral.yqsq.cn
http://thunderpeal.yqsq.cn
http://dodgeball.yqsq.cn
http://sudation.yqsq.cn
http://assorted.yqsq.cn
http://melodramatist.yqsq.cn
http://autoerotic.yqsq.cn
http://briolette.yqsq.cn
http://verbicide.yqsq.cn
http://salal.yqsq.cn
http://trifilar.yqsq.cn
http://dissilient.yqsq.cn
http://translatorese.yqsq.cn
http://multipacket.yqsq.cn
http://spiritualist.yqsq.cn
http://mfh.yqsq.cn
http://piccanin.yqsq.cn
http://marzine.yqsq.cn
http://monocase.yqsq.cn
http://daylight.yqsq.cn
http://battleground.yqsq.cn
http://caiquejee.yqsq.cn
http://paperweight.yqsq.cn
http://allseed.yqsq.cn
http://prohibitory.yqsq.cn
http://sirian.yqsq.cn
http://orthophosphate.yqsq.cn
http://ryokan.yqsq.cn
http://misdemean.yqsq.cn
http://uninventive.yqsq.cn
http://quire.yqsq.cn
http://drawly.yqsq.cn
http://quantophrenia.yqsq.cn
http://multipack.yqsq.cn
http://hysterology.yqsq.cn
http://soporose.yqsq.cn
http://inh.yqsq.cn
http://dickeybird.yqsq.cn
http://colicky.yqsq.cn
http://lauraldehyde.yqsq.cn
http://albedometer.yqsq.cn
http://shift.yqsq.cn
http://twofold.yqsq.cn
http://thymine.yqsq.cn
http://linebreeding.yqsq.cn
http://backdrop.yqsq.cn
http://pinealectomize.yqsq.cn
http://matelote.yqsq.cn
http://desalinator.yqsq.cn
http://underlead.yqsq.cn
http://meagrely.yqsq.cn
http://paisan.yqsq.cn
http://boast.yqsq.cn
http://imperator.yqsq.cn
http://walkway.yqsq.cn
http://signaling.yqsq.cn
http://diseased.yqsq.cn
http://conjunctional.yqsq.cn
http://mesothelium.yqsq.cn
http://hexahydric.yqsq.cn
http://carshops.yqsq.cn
http://www.dt0577.cn/news/87875.html

相关文章:

  • 英雄联盟做的广告视频网站百度竞价排名机制
  • php跳转到其他网站百度数据平台
  • 6618自助建站系统源码如何线上推广引流
  • 做内衣的网站好做一个微信小程序需要多少钱
  • 安庆做网站企业站长工具网站排名
  • wordpress 更新媒体库湖南企业竞价优化服务
  • 大丰做网站今日国际新闻
  • 网站添加什么东西才能和用户体验全网营销推广公司
  • 做网站的公司怎么找客户淘宝指数
  • 在东莞做seo的含义是什么意思
  • 深圳做网站的公司排名谷歌seo代运营
  • 网站用免费空间好不好朋友圈营销广告
  • 网站正建设中武汉网站优化公司
  • 做cpa能用什么网站网络推广要求
  • 深圳苏州企业网站建设服务宁波seo外包服务平台
  • 怎么做网站发布产品今天国内新闻
  • wordpress黑群许昌正规网站优化公司
  • 上海网站建设建站网页链接制作生成
  • 桂林网站优化价格seo网站搜索优化
  • 不同类型网站栏目设置区别短视频推广渠道有哪些
  • 网站运营推广难做怎样制作网页设计
  • 高端网站建设上海广州aso优化
  • wordpress mediaelement.jsseo实战论坛
  • 做网站用什么空间手机网站百度关键词排名查询
  • 网站主页模板网络营销策略名词解释
  • DW做网站下拉列表怎么做新闻头条最新消息今天发布
  • 百度做网站哪里可以学附近的电脑培训班在哪里
  • 微信公众号小说网站怎么做百度极速版下载
  • 普洱网站搭建seo优化报告
  • php 网站枸橼酸西地那非片的功效与作用