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

网上商城网站建设方案书网络策划与营销

网上商城网站建设方案书,网络策划与营销,购买网站空间大小,免费APP 微信 网站平台阿华代码,不是逆风,就是我疯 你们的点赞收藏是我前进最大的动力!! 希望本文内容能够帮助到你!! 目录 第一题:移动零 第二题:复写零 第三题:快乐数 第四题&#xff1a…

 8e19eee2be5648b78d93fbff2488137b.png

阿华代码,不是逆风,就是我疯

你们的点赞收藏是我前进最大的动力!!

希望本文内容能够帮助到你!!

目录

第一题:移动零

第二题:复写零

第三题:快乐数

第四题:盛最多水的容器

第五题:有效三角形的个数

第六题:和为s的两个数

第七题:三数之和

第八题:四数之和


 

 

第一题:移动零

283. 移动零 - 力扣(LeetCode)

dc170944f8264779a0529ff8bc82ab4d.png

6dd9fe7273084b61845aacc2605c8a76.png

class Solution {public void moveZeroes(int[] nums) {int dest = -1;int cur = 0;int tem = 0;while(cur < nums.length){if(nums[cur] != 0){dest++;tem = nums[dest] ;nums[dest] = nums[cur];nums[cur] = tem;}cur++;}}
}

第二题:复写零

1089. 复写零 - 力扣(LeetCode)

249c2e799cd2473388d21fce909a5f8e.png

913e5ee615a444928523b49d78e47471.png

class Solution {public void duplicateZeros(int[] arr) {int cur = 0 , dest = -1 , n = arr.length;while(cur <= n){//dest位置不确定所以不能用作判断循环的条件if(arr[cur] != 0){dest++;}else{dest += 2;}if(dest >= n-1){break;}cur++;}if(dest == n){arr[n-1] = 0;dest -= 2;cur--;}//开始从后往前复写while(cur >= 0 ){if(arr[cur] != 0){arr[dest] = arr[cur];cur--;dest--;}else{arr[dest] = arr[cur];dest--;arr[dest] = arr[cur];cur--;dest--;}}}
}

第三题:快乐数

202. 快乐数 - 力扣(LeetCode)

aeba3d1463834acd9af530221afb1078.png

02762e2f156742f98611d3fce4b8a0a9.png

a33cb7dbe06b482b9a087cdc6a3893d7.png

class Solution {public static int sumResult(int n){int sum = 0;while(n != 0){//int tem = n % 10;//sum += tem * tem;sum += Math.pow(n%10,2);n = n/10;}return sum;} public boolean isHappy(int n) {int slow = n ,fast = sumResult(n);while(slow != fast){slow = sumResult(slow);fast = sumResult(sumResult(fast));}return slow == 1;}
}

第四题:盛最多水的容器

11. 盛最多水的容器 - 力扣(LeetCode)

6d0ea7a48fca4af88a38d01616b17e6c.png

1d94eea0dbd84c8aba1245d6d3282a4b.png

class Solution {public int maxArea(int[] height) {int left = 0 ,right = height.length -1 , ret = 0;while(left < right){int v = Math.min(height[left],height[right]) * (right - left);ret = Math.max(ret,v);if(height[left] < height[right]){left++;}else{right--;}}return ret;}
}

第五题:有效三角形的个数

611. 有效三角形的个数 - 力扣(LeetCode)

228e26d7d962483b83c553ba1b02f2e7.png

c7ed088cd3f64b4d8ac1e859ae1bceec.png

class Solution {public int triangleNumber(int[] nums) {int end = nums.length-1;Arrays.sort(nums);int count = 0;for( ; end >= 2 ; end--){int right = end-1;int left = 0;while(left < right){int tem = nums[left] + nums[right];if(tem > nums[end]){count += right - left;right--;}else{left++;}}            } return count;}
}

 

第六题:和为s的两个数

LCR 179. 查找总价格为目标值的两个商品 - 力扣(LeetCode)

bd601b781b184576803517b67f06883e.png

 

8303f5bdfba743fba3a88d5111e094f9.png

class Solution6 {public int[] twoSum(int[] price, int target) {int n = price.length;int left = 0 , right = n-1;int[] car = {-1,-1};while(left < right){int result = sum(price[left],price[right]);if(result < target){left++;}else if(result > target){right--;}else{car[0] = price[left];car[1] = price[right];return car;}}return car;}public int sum(int a , int b){int sum = a + b;return sum;}
}

第七题:三数之和

15. 三数之和 - 力扣(LeetCode)

7c4131c6891446459ae1280f0c087b7c.png1a956207fbf34b489499ac5952970b4f.png

c93304014deb493689333cc6fadef7be.png

07a52397256e46a196d045444ee3c985.png

class Solution {public List<List<Integer>> threeSum(int[] nums) {Arrays.sort(nums);int n = nums.length;List<List<Integer>> ret = new ArrayList<>();for(int i = 0 ; i < n ;){if(nums[i] > 0){break;}int left = i+1 , right = n-1 ,target = -nums[i];while(left < right){int sum = sum(nums[left] , nums[right]);if(sum > target){right--;}else if(sum < target){left++;    }else{ret.add(Arrays.asList(nums[left] , nums[right] , nums[i]));left++;right--;while(left < right && nums[left] == nums[left - 1]){left++;}while(left < right && nums[right] == nums[right + 1]){right--;}}}i++;while(i < n && nums[i] == nums[i-1]){i++;}}return ret;}public int sum(int a , int b){return a+b;}
}

第八题:四数之和

18. 四数之和 - 力扣(LeetCode)

强烈建议先把三数之和看完

86885d57ac144a26a092fc447bb4cedb.pngb5f2282a187f4384afe316c9c019953a.png

5e777747202b437ab2625950f1d58a2c.png

 

class Solution {public List<List<Integer>> fourSum(int[] nums, int target) {List<List<Integer>> list = new ArrayList();Arrays.sort(nums);int n = nums.length;for(int i = 0 ; i < n ; ){//第一层循环遍历固定a遍历数组int a = nums[i];for(int j = i+1 ; j < n ; ){int b = nums[j] , left = j+1 ,right = n-1;long tem = (long)target - a - b;while(left < right){long sum = sum(nums[left],nums[right]);if(sum > tem){right--;}else if(sum < tem){left++;}else{list.add(Arrays.asList(a,b,nums[left],nums[right]));left++;right--;while(left < right && nums[left] == nums[left-1]){left++;}while(right > left && nums[right] == nums[right+1]){right--;}}}j++;while(j < n-2 && nums[j] == nums[j-1]){j++;}}i++;while(i < n-1 && nums[i] == nums[i-1]){i++;}}return list;}public int sum(int a , int b){return a+b;}
}

 

 

http://www.hkea.cn/news/277800/

相关文章:

  • 免费单页网站在线制作沈阳seo排名优化教程
  • 廊坊网站建大型网站建站公司
  • 远程桌面做网站sem和seo区别与联系
  • 做贷款网站优化大师有用吗
  • 有没有便宜的网站制作制作网页教程
  • 医院网站制作优化关键词的方法有哪些
  • wordpress安装到网站吗泰安seo
  • 长春网站开发培训价格google play三件套
  • 做生存分析的网站有哪些国外新闻最新消息
  • 济南网站优化收费百度互联网营销
  • bootstrap响应网站模板下载发帖推广百度首页
  • 动态网站上的查询怎么做新媒体运营培训学校
  • 网站开发人员必备技能百度优化推广
  • 花都 网站建设百度推广怎么添加关键词
  • 开发公司成本部职责岗位职责和流程苏州网站建设优化
  • 湛江网站制作系统seo排名需要多少钱
  • 城乡现代社区建设seo关键词推广案例
  • 旅游网站开发外文文献关键洞察力
  • 大学生asp网站开发的实训周长沙百度快速优化
  • 黑龙江省建设网站百度投流运营
  • 网站关键词太多好不好兰州seo整站优化服务商
  • 义乌网站设计网店推广策划方案
  • 无锡网站优化工作室网站关键词排名优化推广软件
  • 长沙做网站的公司亚马逊seo什么意思
  • 仪征建设银行官方网站怎么优化一个网站
  • 那个网站可以查询美做空基金宁波网站推广平台效果好
  • 杨凌企业网站建设天津seo优化
  • 建设网站的工具免费b站在线观看人数在哪儿
  • 毕业设计餐饮网站建设国内前10电商代运营公司
  • 日本b2b网站市场调研的步骤