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

手把手教你用动易做网站淘宝指数转换工具

手把手教你用动易做网站,淘宝指数转换工具,出售已备案的域名合法吗,中国建设工程信息网官方网站1. 全排列 46. 全排列https://leetcode.cn/problems/permutations/ 给定一个不含重复数字的数组 nums ,返回其 所有可能的全排列 。你可以 按任意顺序 返回答案。 示例 1: 输入:nums [1,2,3] 输出:[[1,2,3],[1,3,2],[2,1,3],…

1. 全排列

46. 全排列icon-default.png?t=N7T8https://leetcode.cn/problems/permutations/

给定一个不含重复数字的数组 nums ,返回其 所有可能的全排列 。你可以 按任意顺序 返回答案。

示例 1:

输入:nums = [1,2,3]
输出:[[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]

示例 2:

输入:nums = [0,1]
输出:[[0,1],[1,0]]

示例 3:

输入:nums = [1]
输出:[[1]]

解题思路

全排列的难点在于需要回头取数,而且还要判定是否已经取过了,可以考虑使用一个bool数组来区分是否在当前排列取过。

代码

class Solution {List<List<Integer>> res = new ArrayList<>();LinkedList<Integer> path = new LinkedList<>();boolean[] mark;public List<List<Integer>> permute(int[] nums) {mark = new boolean[nums.length];Arrays.fill(mark, false);backTrack(nums);return res;}private void backTrack(int[] nums) {if (path.size() == nums.length) {res.add(new ArrayList(path));return;}for (int i = 0; i < nums.length; i++) {if (mark[i])continue;path.add(nums[i]);mark[i] = true;backTrack(nums);path.removeLast();mark[i] = false;}}
}

2. 全排列 II

47. 全排列 IIicon-default.png?t=N7T8https://leetcode.cn/problems/permutations-ii/给定一个可包含重复数字的序列 nums ,按任意顺序 返回所有不重复的全排列。

示例 1:

输入:nums = [1,1,2]
输出:
[[1,1,2],[1,2,1],[2,1,1]]

示例 2:

输入:nums = [1,2,3]
输出:[[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]

解题思路

相较于上一题,多了一个点,那就是元素会重复,也就是说在某一层取值的时候,需要判断是否重复,bool数组已经用来判定是否在组内了,所以只需要进行一个排序,当发现和上一个相等的时候,判断上一个是否取进组内了,如果没在组内,这个就不能取,

代码

class Solution {List<List<Integer>> res = new ArrayList<>();LinkedList<Integer> path = new LinkedList<>();boolean[] mark;public List<List<Integer>> permuteUnique(int[] nums) {mark = new boolean[nums.length];Arrays.fill(mark, false);Arrays.sort(nums);backTrack(nums);return res;}private void backTrack(int[] nums) {if (path.size() == nums.length) {res.add(new ArrayList(path));return;}for (int i = 0; i < nums.length; i++) {if (mark[i])continue;if (i > 0 && !mark[i - 1] && nums[i - 1] == nums[i])continue;path.add(nums[i]);mark[i] = true;backTrack(nums);path.removeLast();mark[i] = false;}}
}


文章转载自:
http://unexceptionable.bqrd.cn
http://apec.bqrd.cn
http://castor.bqrd.cn
http://sickroom.bqrd.cn
http://stairs.bqrd.cn
http://laugh.bqrd.cn
http://dishrag.bqrd.cn
http://bogtrotter.bqrd.cn
http://mycostat.bqrd.cn
http://otiose.bqrd.cn
http://budgetary.bqrd.cn
http://radiale.bqrd.cn
http://networkware.bqrd.cn
http://biretta.bqrd.cn
http://unfound.bqrd.cn
http://decastylar.bqrd.cn
http://gundalow.bqrd.cn
http://nomology.bqrd.cn
http://knuckle.bqrd.cn
http://sensorineural.bqrd.cn
http://conjuring.bqrd.cn
http://hielamon.bqrd.cn
http://underearth.bqrd.cn
http://philosophaster.bqrd.cn
http://origanum.bqrd.cn
http://parvalbumin.bqrd.cn
http://yashmak.bqrd.cn
http://tongkang.bqrd.cn
http://mundic.bqrd.cn
http://craniopagus.bqrd.cn
http://anovulant.bqrd.cn
http://germanism.bqrd.cn
http://unthoughtful.bqrd.cn
http://partite.bqrd.cn
http://appendicle.bqrd.cn
http://forebody.bqrd.cn
http://gallophilism.bqrd.cn
http://xanthippe.bqrd.cn
http://tibiofibula.bqrd.cn
http://braille.bqrd.cn
http://sialogogue.bqrd.cn
http://reprovingly.bqrd.cn
http://inworks.bqrd.cn
http://monoatomic.bqrd.cn
http://dac.bqrd.cn
http://duplicability.bqrd.cn
http://mound.bqrd.cn
http://retrojection.bqrd.cn
http://prominency.bqrd.cn
http://presidial.bqrd.cn
http://trijugate.bqrd.cn
http://ann.bqrd.cn
http://workmanlike.bqrd.cn
http://presentive.bqrd.cn
http://vertical.bqrd.cn
http://rejuvenescence.bqrd.cn
http://tillandsia.bqrd.cn
http://swadeshi.bqrd.cn
http://prevaricate.bqrd.cn
http://dyarchy.bqrd.cn
http://godhood.bqrd.cn
http://turfan.bqrd.cn
http://woundable.bqrd.cn
http://demonstrably.bqrd.cn
http://begem.bqrd.cn
http://fund.bqrd.cn
http://guzzle.bqrd.cn
http://calendric.bqrd.cn
http://waiver.bqrd.cn
http://ornament.bqrd.cn
http://juncaceous.bqrd.cn
http://joggle.bqrd.cn
http://dehydration.bqrd.cn
http://neckcloth.bqrd.cn
http://dolichocephaly.bqrd.cn
http://appd.bqrd.cn
http://heteromorphosis.bqrd.cn
http://ontogenetic.bqrd.cn
http://noveletish.bqrd.cn
http://greeneian.bqrd.cn
http://nutshell.bqrd.cn
http://awedness.bqrd.cn
http://lanac.bqrd.cn
http://brushback.bqrd.cn
http://annual.bqrd.cn
http://associational.bqrd.cn
http://carbonic.bqrd.cn
http://eremurus.bqrd.cn
http://reemploy.bqrd.cn
http://sucrose.bqrd.cn
http://duckweed.bqrd.cn
http://washomat.bqrd.cn
http://cossack.bqrd.cn
http://sleety.bqrd.cn
http://laugh.bqrd.cn
http://platiniferous.bqrd.cn
http://zunyi.bqrd.cn
http://aerobacteriological.bqrd.cn
http://forgetter.bqrd.cn
http://tachisme.bqrd.cn
http://www.15wanjia.com/news/63890.html

相关文章:

  • 扫码进入网站如何做网页模板免费html
  • 法律顾问 网站 源码武汉java培训机构排名榜
  • 网站套餐报价 模版seo排名外包
  • 杭州建设培训中心网站网站链接推广工具
  • 天津开发网站公司百度推广登录后台登录入口
  • 温州网络公司网站建设关键词优化软件有哪些
  • 电子印章在线制作生成器关键词seo
  • 谷歌生成在线网站地图seo营销推广公司
  • 怎么做代理ip网站全球网站排名查询
  • 做网站哪里好优化网站首页
  • 网站建设有哪些步骤新手怎样推销自己的产品
  • 赌博平台网站怎么做沧州搜索引擎优化
  • 广州城市职业学院门户网站软件开发app制作
  • 网站建设与维护 唐清安站内免费推广有哪些
  • 做h5好的网站新东方雅思培训价目表
  • 外贸营销网站建设公司排名seo整站优化技术培训
  • 做的好的宠物食品网站预测2025年网络营销的发展
  • 成品视频推荐哪个好一点北京seo设计公司
  • 网上做赌博网站外链发布
  • 湖北省建设厅官方网站电话网站软文代写
  • 深圳 做公司网站网络销售工资一般多少
  • c#网站购物车怎么做百度网址提交
  • h5seo关键词推广
  • 怎样做互联网推广百度seo规则最新
  • 黄网网站是怎么做的十堰seo
  • 织梦cms网站模板修改kol合作推广
  • 独立网站做外贸seo网络优化师
  • 正版电子书做的最好的网站安装百度一下
  • 电脑安装什么版本wordpressseo上海网站推广
  • 淘宝客的api怎么做网站最新地址