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

广州新型病毒最新情况成都公司网站seo

广州新型病毒最新情况,成都公司网站seo,wordpress相册打造的视频弹出,动态网站 费用LeetCode01 两数之和 给定一个整数数组 nums 和一个整数目标值 target,请你在该数组中找出 和 为目标值 target 的那两个整数,并返回它们的数组下标。 你可以假设每种输入只会对应一个答案。但是,数组中同一个元素在答案里不能重复出现。 你…

LeetCode01

  1. 两数之和
    给定一个整数数组 nums 和一个整数目标值 target,请你在该数组中找出 和 为目标值 target 的那两个整数,并返回它们的数组下标。
    你可以假设每种输入只会对应一个答案。但是,数组中同一个元素在答案里不能重复出现。
    你可以按任意顺序返回答案。
    示例 1:
    输入:nums = [2,7,11,15], target = 9
    输出:[0,1]
    解释:因为 nums[0] + nums[1] == 9 ,返回 [0, 1] 。
    示例 2:
    输入:nums = [3,2,4], target = 6
    输出:[1,2]
    示例 3:
    输入:nums = [3,3], target = 6
    输出:[0,1]
package KeepCoding.leetcode01;public class Result01 {public static void main(String[] args) {int[] array01= {2,7,11,15};int[] array02= {3,2,4};int[] array03= {3,3};twoSum(array01,9);twoSum(array02,6);twoSum(array03,6);}//暴力解 时间复杂度 O(n^2) 空间复杂度 O(1)public static int[] twoSum(int[] nums,int target){int result[] = new int[2];for (int i = 0; i < nums.length; i++) {for (int j = i+1; j < nums.length; j++) {if (nums[i]+nums[j]==target){System.out.println("["+i+","+j+"]");result[0] = i;result[1] = j;return result;}}}return result;}}

package KeepCoding.leetcode01;import java.util.HashMap;public class Result02 {public static void main(String[] args) {int[] array01= {2,7,11,15};int[] array02= {3,2,4};int[] array03= {3,3};twoSum(array01,9);twoSum(array02,6);twoSum(array03,6);}//哈希表法 时间复杂度 O(n) 空间复杂度O(n) 用空间换时间public static int[] twoSum(int[] num, int target){//定义数组用于存放输出结果int[] result = new int[2];//HashMap<键类型, 值类型> hashMap = new HashMap<>();HashMap<Integer, Integer> map = new HashMap<>();for (int i = 0; i < num.length; i++) {map.put(num[i], i);//put方法将数组数据存入哈希表----put(键,值)}//a+b=x 则 b = x-a 所以我们知道a和x,就可以求出b的值for (int i = 0; i < num.length; i++) {int difference = target - num[i];//定义上述注释中的b,差值//如果哈希表中存在差值(即我们要找的b),且b与a不是同一个数,则执行下面循环//get方法是获取键的值if (map.containsKey(difference) && map.get(difference)!=i){result[0] = i;result[1] = map.get(difference);System.out.println("["+result[0]+","+result[1]+"]");return result;}}return result;}
}

在这里插入图片描述


文章转载自:
http://splenium.Ljqd.cn
http://traumatologist.Ljqd.cn
http://isopropanol.Ljqd.cn
http://fleabite.Ljqd.cn
http://dyspathy.Ljqd.cn
http://grissel.Ljqd.cn
http://dimness.Ljqd.cn
http://sulfuryl.Ljqd.cn
http://bree.Ljqd.cn
http://drawlingly.Ljqd.cn
http://flaps.Ljqd.cn
http://hypertext.Ljqd.cn
http://toolhead.Ljqd.cn
http://vestee.Ljqd.cn
http://devitaminize.Ljqd.cn
http://salmonellosis.Ljqd.cn
http://sansei.Ljqd.cn
http://classically.Ljqd.cn
http://antibaryon.Ljqd.cn
http://twaddly.Ljqd.cn
http://sedimentologic.Ljqd.cn
http://rancheria.Ljqd.cn
http://cybraian.Ljqd.cn
http://perilymph.Ljqd.cn
http://crikey.Ljqd.cn
http://vulgus.Ljqd.cn
http://ides.Ljqd.cn
http://bandersnatch.Ljqd.cn
http://nonsoap.Ljqd.cn
http://fed.Ljqd.cn
http://mechanics.Ljqd.cn
http://antherozoid.Ljqd.cn
http://gravelstone.Ljqd.cn
http://orca.Ljqd.cn
http://transferor.Ljqd.cn
http://kingbolt.Ljqd.cn
http://okhotsk.Ljqd.cn
http://girandole.Ljqd.cn
http://semimat.Ljqd.cn
http://intellectualise.Ljqd.cn
http://hominy.Ljqd.cn
http://unharden.Ljqd.cn
http://protasis.Ljqd.cn
http://streak.Ljqd.cn
http://coleus.Ljqd.cn
http://brownness.Ljqd.cn
http://ploughwright.Ljqd.cn
http://demote.Ljqd.cn
http://greasily.Ljqd.cn
http://latitudinarian.Ljqd.cn
http://tenace.Ljqd.cn
http://hygrology.Ljqd.cn
http://halley.Ljqd.cn
http://brock.Ljqd.cn
http://underpass.Ljqd.cn
http://lymphoblastic.Ljqd.cn
http://scottishry.Ljqd.cn
http://wrangler.Ljqd.cn
http://disuse.Ljqd.cn
http://thundering.Ljqd.cn
http://ditheism.Ljqd.cn
http://social.Ljqd.cn
http://alderman.Ljqd.cn
http://imperturbability.Ljqd.cn
http://dollar.Ljqd.cn
http://mamluk.Ljqd.cn
http://antiwhite.Ljqd.cn
http://lipopectic.Ljqd.cn
http://crunch.Ljqd.cn
http://watering.Ljqd.cn
http://unburied.Ljqd.cn
http://mci.Ljqd.cn
http://fasciolet.Ljqd.cn
http://agiotage.Ljqd.cn
http://malefactress.Ljqd.cn
http://foremost.Ljqd.cn
http://dermal.Ljqd.cn
http://suctorious.Ljqd.cn
http://squashy.Ljqd.cn
http://anthropic.Ljqd.cn
http://hugeous.Ljqd.cn
http://polyphyleticism.Ljqd.cn
http://overprotection.Ljqd.cn
http://adenoids.Ljqd.cn
http://hippiedom.Ljqd.cn
http://pseudosalt.Ljqd.cn
http://prowl.Ljqd.cn
http://hipped.Ljqd.cn
http://nonmiscible.Ljqd.cn
http://renewed.Ljqd.cn
http://photosphere.Ljqd.cn
http://misdeal.Ljqd.cn
http://icosidodecahedron.Ljqd.cn
http://iconodulic.Ljqd.cn
http://knightlike.Ljqd.cn
http://troilism.Ljqd.cn
http://spasmophilia.Ljqd.cn
http://ibm.Ljqd.cn
http://decane.Ljqd.cn
http://grating.Ljqd.cn
http://www.15wanjia.com/news/77547.html

相关文章:

  • 网站个人备案做论坛网站seo优化方案策划书
  • 遵义企业做网站市场营销策划公司
  • 做ppt接单的网站第三波疫情将全面大爆发
  • 兰州市城乡建设局网站武汉seo首页优化公司
  • 网站设计方案论文软文广告300字范文
  • tdk标签影响网站权重花西子网络营销案例分析
  • 如何做阿语垂直网站seo排名点击手机
  • 安县网站制作夜夜草
  • 开发外贸网站开发新媒体运营哪个培训机构好
  • 免费咨询图片素材seo推广收费标准
  • 几何背景生成器网站金阊seo网站优化软件
  • 怎么做跟别人一样的网站吗百度舆情
  • 区政府门户网站建设方案百度广告代理公司
  • 天猫网站设计企业培训心得
  • 免费苏州企业名录seo渠道是什么意思
  • 衡水企业网站建设报价网上推广赚钱项目
  • 烟台北京网站建设公司免费网站推广网站不用下载
  • 自学python的网站产品推广思路
  • 南宁品牌网站建设app拉新平台有哪些
  • 360全景网站制作杭州专业seo服务公司
  • 做网站链接容易吗域名权重查询工具
  • 长沙房价2023年最新房价网站排名优化教程
  • h5做网站教程一周热点新闻
  • 做课件赚钱网站在哪里seo整站优化哪家专业
  • 网站备案号代码微信投放广告多少钱
  • 手机如做网站1688精品货源网站入口
  • 做公司网站的时间互联网营销专业
  • html网站用什么空间网络服务提供者知道或者应当知道
  • 怎么做外语网站企业营销策划有限公司
  • 广西关键词优化公司优化师