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

自己建立网站教程个人怎么做淘宝客网站

自己建立网站教程,个人怎么做淘宝客网站,信息可视化网站,网站建设doc刷题刷到LeetCode回溯DFS的算法题39题的时候,碰见一个Arraylist里面的bug,其中dfs函数里面的第一个if判断里面的语句 paths.add(path); path.clear();其中path是添加了path,但是添加之后path.clear(),导致原来添加到paths的path置为空数组,因为ArrayList的add只是把一个引用指…刷题刷到LeetCode回溯DFS的算法题39题的时候,碰见一个Arraylist里面的bug,其中dfs函数里面的第一个if判断里面的语句 paths.add(path); path.clear();其中path是添加了path,但是添加之后path.clear(),导致原来添加到paths的path置为空数组,因为ArrayList的add只是把一个引用指向了path,并不是深度复制,也就是说不是拷贝了一个新的ArrayList,因此改动原来的path会导致添加到paths的元素同样发生变化,直接也是clear掉了! package org.example.SolutionTest3;import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class Solution {public ListListInteger combinationSum(int[] candidates, int target) {int ncandidates.length;ListInteger pathnew ArrayList();ListListInteger pathsnew ArrayList();return use_dfs(candidates,paths,path,target);}public ListListInteger use_dfs(int[] candidates , ListListInteger paths ,ListInteger path , int target){for(int i 0;icandidates.length;i){dfs(candidates,paths,path,target,target-candidates[i]);}return paths;}public void dfs(int[] candidates , ListListInteger paths ,ListInteger path , int target,int num){if(num0!path.isEmpty()){System.out.println(path path);paths.add(path);path.clear();//pathnew ArrayList();return;}else if(num0!path.isEmpty()){path.remove(path.size()-1);return;}for( int i 0 ; icandidates.length;i){int next_num num-candidates[i];if(next_num0){continue;}path.add(candidates[i]);dfs(candidates,paths,path,target , next_num);}}public static void main(String[] args) {ListListInteger lists new Solution().combinationSum(new int[]{2, 3, 6, 7},7);System.out.println(lists);} }
http://www.dnsts.com.cn/news/104049.html

相关文章:

  • 国外网站页面做多大建一个手机网站需要多少钱
  • 网站建设技术开发江苏市场监督管理局旗舰店
  • 电子商务网站建设需要多少钱网站建设的总结200字
  • 建设网站ppt做阿里巴巴网站图片尺寸
  • 新乡市建设路小学网站wordpress 火车发布
  • 为学校建设网站html5手机wap网站模板
  • 找事做网站怎样开网店详细步骤
  • 网站建设设计哪家好昆明做网站那家好
  • 安徽网站建设系统工程预算培训
  • 沧州开发网站多少钱wordpress取消默认图片
  • 网站开发需求确认书查询企业联系方式的软件
  • 保定网络营销网站中联汇科 网站建设
  • 太极馆如何做网站搬瓦工服务器用来做网站
  • 张家口建设部网站中山网站建设咨询
  • 企业高端网站制作凡科互动公司
  • 小清新网站设计深圳哪里有做网站
  • 海口小微企业网站建设阜阳万维网站建设
  • 网站备案幕布照如何做山东建设监理协会网站
  • 网站制作 信科网络品牌网站的建设
  • 网站开发 京东浙江网站推广公司
  • 站长平台怎么做网站wordpress的cdn加速
  • 做网站公司电话wordpress 简洁模板
  • 做百度推广需要自己有个网站吗高清设计网站推荐
  • 做网站展示软件网站建设如何选择域名
  • 网站建设 企业兼容手机的网站
  • 重庆旅游网站建设公司甘肃兰州事件
  • dede网站建站教程wordpress用户登录注册插件
  • 湖北省建设厅乡镇污水官方网站网页设计与制作课程标准化项目申报书
  • 智能建站的优势和不足如何登录工信部备案系统官网
  • 室内设计平面图讲解百度seo什么意思