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

购物网站开发的意义和目的2022年最火文案

购物网站开发的意义和目的,2022年最火文案,html5 网站平台,模拟建筑4一、Nim 游戏 1、题目链接 点击跳转到题目位置 2、代码 class Solution {public boolean canWinNim(int n) {if(n % 4 0){return false;}return true;} }3、知识点 (1) 通过模拟来寻找 规律。 二、区域和检索 - 数组不可变 1、题目链接 点击跳转到题目位置 2、代码 …

一、Nim 游戏

1、题目链接

点击跳转到题目位置

2、代码

class Solution {public boolean canWinNim(int n) {if(n % 4 == 0){return false;}return true;}
}

3、知识点

(1) 通过模拟来寻找 规律。

二、区域和检索 - 数组不可变

1、题目链接

点击跳转到题目位置

2、代码

class NumArray {int[] sums;public NumArray(int[] nums) {int n = nums.length;sums = new int[n+1];for(int i = 0; i < n; ++i){sums[i + 1] = sums[i] + nums[i];}}public int sumRange(int left, int right) {return sums[right + 1] - sums[left];}
}/*** Your NumArray object will be instantiated and called as such:* NumArray obj = new NumArray(nums);* int param_1 = obj.sumRange(left,right);*/

3、知识点

(1) 使用前缀和来解决问题。

三、3 的幂

1、题目链接

点击跳转到题目位置

2、代码

class Solution {public boolean isPowerOfThree(int n) {if(n <= 0){return false;}while(n > 1){if(n % 3 == 0){n /= 3;} else{return false;}}   return true;}
}

3、知识点

(1) 模拟试除。

四、比特位计数

1、题目链接

点击跳转到题目位置

2、代码

class Solution {public int count(int n){int res = 0;while(n > 0){n &= (n - 1);++res;}return res;}public int[] countBits(int n) {int[] res = new int[n+1];for(int i = 0; i <= n; ++i){res[i] = count(i);}return res;}
}

3、知识点

(1) 位运算,知识点同2的幂。

五、4的幂

1、题目链接

点击跳转到题目位置

2、代码

class Solution {public boolean isPowerOfFour(int n) {return n > 0 && (n & (n - 1)) == 0 && n % 3 == 1;}
}

3、知识点

(1) 位运算,如何判断一个数是2的幂,4的幂除以3的余数等于1。

六、反转字符串

1、题目链接

点击跳转到题目位置

2、代码

class Solution {public void reverseString(char[] s) {int left = 0;int right = s.length - 1;while(left < right){char temp = s[left];s[left] = s[right];s[right] = temp;++left;--right;}}
}

3、知识点

(1) 双指针

七、反转字符串中的元音字母

1、题目链接

点击跳转到题目位置

2、代码

class Solution {public boolean judge(char ch){switch(ch){case 'a':case 'o':case 'i':case 'e':case 'u':case 'A':case 'E':case 'I':case 'O':case 'U':return true;}return false;}public String reverseVowels(String s) {int n = s.length();int left = 0;int right = n - 1;StringBuffer sb = new StringBuffer(s);while(left < right){while(left < n && judge(sb.charAt(left)) == false){++left;}while(right >= 0 && judge(sb.charAt(right)) == false){--right;}if(left > right){break;}char temp = sb.charAt(left);sb.setCharAt(left, sb.charAt(right));sb.setCharAt(right, temp);++left;--right;}  return sb.toString();}
}

3、知识点

(1) 字符串中进行遍历,交换两个字符。

(2) java中switch操作。

八、 两个数组的交集

1、题目链接

点击跳转到题目位置

2、代码

class Solution {public int[] getIntersection(Set<Integer> set1, Set<Integer> set2){if(set1.size() < set2.size()){return getIntersection(set2, set1);}Set<Integer> intersectionSet = new HashSet<Integer>();for(int num : set1){if(set2.contains(num)){intersectionSet.add(num);}}int []res = new int[intersectionSet.size()];int index = 0;for(int num : intersectionSet){res[index++] = num;} return res;}public int[] intersection(int[] nums1, int[] nums2) {Set<Integer> set1 = new HashSet<Integer>();Set<Integer> set2 = new HashSet<Integer>();for(int i = 0; i < nums1.length; ++i){set1.add(nums1[i]);} for(int i = 0; i < nums2.length; ++i){set2.add(nums2[i]);}return getIntersection(set1, set2);}
}

3、知识点

(1) java中的集合。

九、两个数组的交集 II

1、题目链接

点击跳转到题目位置

2、代码

class Solution {public int[] intersect(int[] nums1, int[] nums2) {int len1 = nums1.length;int len2 = nums2.length;int[] hash1 = new int[1005];int[] hash2 = new int[1005];int[] res = new int[Math.min(len1, len2)];for(int i = 0; i < len1; ++i){hash1[nums1[i]]++;}for(int i = 0; i < len2; ++i){hash2[nums2[i]]++;}int index = 0;for(int i = 0; i <= 1000; ++i){int num = Math.min(hash1[i], hash2[i]);while(num > 0){--num;res[index] = i;++index;}}return Arrays.copyOfRange(res, 0, index);}
}

3、知识点

(1) 哈希表解决。

十、有效的完全平方数

1、题目链接

点击跳转到题目位置

2、代码

class Solution {public boolean isPerfectSquare(int num) {if((int)Math.sqrt(num) * (int)Math.sqrt(num) != num){return false;}return true;}
}

3、知识点

(1) 利用**内置函数sqrt()**即可。

十一、猜数字大小

1、题目链接

点击跳转到题目位置

2、代码

/** * Forward declaration of guess API.* @param  num   your guess* @return 	     -1 if num is higher than the picked number*			      1 if num is lower than the picked number*               otherwise return 0* int guess(int num);*/public class Solution extends GuessGame {public int guessNumber(int n) {int left = 1;int right = n;while(left <= right){int mid = ((right - left) >> 1) + left;if(guess(mid) == -1){right = mid - 1;} else if(guess(mid) == 0){return mid;} else{left = mid + 1;}}return 0;}
}

3、知识点

(1) 二分搜索即可。

十二、赎金信

1、题目链接

点击跳转到题目位置

2、代码

class Solution {public boolean canConstruct(String ransomNote, String magazine) {int[] hash1 = new int[26];int[] hash2 = new int[26];for(int i = 0; i < ransomNote.length(); ++i){hash1[ransomNote.charAt(i) - 'a']++;}for(int i = 0; i < magazine.length(); ++i){hash2[magazine.charAt(i) - 'a']++;}for(int i = 0; i < 26; ++i){if(hash1[i] > hash2[i]){return false;}}return true;}
}

3、知识点

(1) 用数组来模拟哈希表

十三、字符串中的第一个唯一字符

1、题目链接

点击跳转到题目位置

2、代码

class Solution {public int firstUniqChar(String s) {int[] hash1 = new int[26];for(int i = 0; i < s.length(); ++i){hash1[s.charAt(i) - 'a']++;}for(int i = 0; i < s.length(); ++i){if(hash1[s.charAt(i) - 'a'] == 1){return i;}}return -1;}
}

3、知识点

(1) 哈希表来统计字符数量。

十四、找不同

1、题目链接

点击跳转到题目位置

2、代码

class Solution {public char findTheDifference(String s, String t) {int[] hash1 = new int[26];int[] hash2 = new int[26];for(int i = 0; i < s.length(); ++i){hash1[s.charAt(i) - 'a']++;}for(int i = 0; i < t.length(); ++i){hash2[t.charAt(i) - 'a']++;}for(int i = 0; i < 26; ++i){if(hash1[i] != hash2[i]){return (char)(i + 'a'); }}return ' ';}
}

3、知识点

(1) 哈希表统计字符串。

十五、判断子序列

1、题目链接

点击跳转到题目位置

2、代码

class Solution {public boolean isSubsequence(String s, String t) {int i = 0;int j = 0;int m = s.length();int n = t.length();while(i < m && j < n){if(s.charAt(i) == t.charAt(j)){++i;++j;} else{++j;}}if(i != m){return false;}return true;}
}

3、知识点

(1) 双指针解决问题。

http://www.jinmujx.cn/news/118481.html

相关文章:

  • 购物网站开发可行性免费b站推广网站短视频
  • 上海哪里有做网站的短视频怎么赚钱
  • 浙江宝业建设集团网站免费智能seo收录工具
  • dnf游戏币交易网站建设chrome手机安卓版
  • 制作微信小程序软件济南seo的排名优化
  • 周口做网站公司哪家好网站关键词优化系统
  • 包头市住房和城乡建设局官方网站网站优化方法
  • 企业负责人电话名录seo模拟点击工具
  • 做销售的 都有什么网站百度员工收入工资表
  • 广州定制网站建设电商培训心得体会
  • 大气集团网站b站推广链接
  • h5商城网站是什么意思百度网站客服
  • 免费个人网站+上传西安百度公司
  • 钓鱼网站怎样做小程序seo
  • 贵州省住房和城乡建设局网站注册域名费用一般多少钱
  • 免费网站建设好不好网址怎么创建
  • 在百度做橱柜网站网络营销产品的首选产品
  • 怎么查找网站建设网站流量指标有哪些
  • 都是做面食网站平面设计培训
  • 一家专门做开网店的网站seo博客模板
  • 网站手机端做排名百度营稍
  • 北京做网站找谁品牌推广内容
  • 网站开发是干什么的爱站网长尾关键词挖掘工具福利片
  • 免费图纸网seo优化公司
  • 链家做网站和手机app花了多少钱线下引流推广方法
  • 滕州做网站的多少企点官网
  • 怎样做网站漂浮发稿媒体平台
  • 响应式网站对seoseo小白入门
  • 学校网站备案怎么做市场推广计划方案模板
  • 淘宝客网站开发上架广州竞价托管代运营