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

网上做平面设计的网站seo优化一般包括哪些内容

网上做平面设计的网站,seo优化一般包括哪些内容,哪个网站美丽乡村做的比较好,石家庄商城网站建设问题描述(感觉n的位数需要大于等于2,因为n的位数1的话会有点问题,“且无重复”是指nums中存在重复,但是最后返回的小于n最大数是可以重复使用nums中的元素的): 思路: 先对nums倒序排序 暴力回…

问题描述(感觉n的位数需要大于等于2,因为n的位数=1的话会有点问题,“且无重复”是指nums中存在重复,但是最后返回的小于n最大数是可以重复使用nums中的元素的):

在这里插入图片描述

思路:

先对nums倒序排序 + 暴力回溯 + 剪枝优化
在这里插入图片描述

代码(含详细注释):

class Solution {public int ans = 0;public int getMaxNum(int[] nums, int n) { // 默认n的位数大于等于2// ① 降序排序Arrays.sort(nums);int left = 0, right = nums.length - 1;while (left < right) {int temp = nums[left];nums[left] = nums[right];nums[right] = temp;left++;right--;}// ② 试图寻找一个小于n的整数(位数和n一样)String nStr = String.valueOf(n);boolean isFound = dfs(nums, nStr, new ArrayList<>(), true);// ③ 比如这种情况,nums: 9 8 7, n: 123,nums中最小的数都比n要大,那么isFound是falseif (!isFound) {for (int i = 0; i < nStr.length() - 1; i++) {ans = ans * 10 + nums[0]; // 比n少一位,然后由nums的最大元素组装而成}}return ans;}public boolean dfs(int[] nums, String nStr, List<Integer> path, boolean preIsEqual) {if (path.size() == nStr.length()) { // 递归出口。如果当前路径的数字已经达到整数n的位数了long pathSum = 0;for (int i = 0; i < path.size(); i++) {pathSum = pathSum * 10 + path.get(i);}// 如果 path: 444, n: 444 全部位置的数字相等也不行if (pathSum < Integer.parseInt(nStr)) {ans = (int) pathSum;return true; // 表示已经找到了}return false; // 有可能是, path: 444, n: 444,全部位置的数字相等也不行}for (int i = 0; i < nums.length; i++) {if (preIsEqual) { // 如果前面几位的数字,path对应的数和n对应位的数相等, 如: path:44_, n:444// 如果前面几位的数字,path对应的数和n对应位的数相等,且当前位数字nums[i]>n对应的位的数,那就剪枝if (nums[i] > nStr.charAt(path.size()) - '0') continue;// 否则可以加入路径path.add(nums[i]);boolean curFlag = dfs(nums, nStr, path, nums[i] == nStr.charAt(path.size()-1) - '0');if (curFlag) return true; // 找到了,直接返回path.remove(path.size() - 1);} else { // 如果前面几位的数字,path对应的数和n对应位的数完全不相等或者不都相等, 如: path:44_, n:543path.add(nums[i]);// 如果前面几位的数字,path对应的数和n对应位的数完全不相等或者不都相等, 那么后面的递归都将是不相等的boolean curFlag = dfs(nums, nStr, path, false);if (curFlag) return true; // 找到了,直接返回path.remove(path.size() - 1);}}return false; // 没找到}
}

测试

测试类

class SolutionTest {public static void test(int[] nums, int n, int expected) {Solution solution = new Solution();int result = solution.getMaxNum(nums, n);if (result != expected) {System.out.println("测试失败!");System.out.println("输入数组: " + arrayToString(nums));System.out.println("目标数: " + n);System.out.println("期望结果: " + expected);System.out.println("实际结果: " + result);System.out.println("------------------------");} else {System.out.println("测试通过: " + arrayToString(nums) + " -> " + n + " = " + result);}}private static String arrayToString(int[] arr) {StringBuilder sb = new StringBuilder("[");for (int i = 0; i < arr.length; i++) {sb.append(arr[i]);if (i < arr.length - 1) {sb.append(", ");}}sb.append("]");return sb.toString();}public static void main(String[] args) {// 基本测试test(new int[]{1, 2, 9, 8}, 100, 99);test(new int[]{4, 5}, 445, 444);test(new int[]{4, 5}, 45, 44);// 边界情况test(new int[]{1, 9}, 10, 9);test(new int[]{9, 8}, 9, 8);test(new int[]{9}, 100, 99);// 所有数字都大于目标数test(new int[]{9, 8, 7}, 123, 99);test(new int[]{9, 8, 7}, 12, 9);// 复杂数字组合test(new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9}, 3000, 2999);test(new int[]{1, 2, 8, 9}, 2990, 2989);// 相同数字test(new int[]{4}, 445, 444);test(new int[]{4}, 45, 44);test(new int[]{4}, 4445, 4444);// 大数测试test(new int[]{9}, 100000, 99999);test(new int[]{8, 9}, 99000, 98999);// 特殊数字组合test(new int[]{1, 2, 3}, 300, 233);test(new int[]{2, 8}, 290, 288);test(new int[]{2, 8, 9}, 289, 288);// 多位数测试test(new int[]{6, 7, 8, 9}, 9877, 9876);test(new int[]{6, 7, 8, 9}, 9868, 9867);// 相邻数字test(new int[]{8, 9}, 1000, 999);test(new int[]{8, 9}, 999, 998);// 混合数字test(new int[]{5, 9}, 6000, 5999);test(new int[]{5, 8, 9}, 5990, 5989);test(new int[]{5, 8, 9}, 5900, 5899);// 包含零test(new int[]{0, 9}, 100, 99);test(new int[]{0, 9}, 1000, 999);// 特殊序列test(new int[]{1, 2, 3, 4, 5, 6}, 54322, 54321);test(new int[]{0, 2, 3, 4, 5, 6}, 54321, 54320);// 重复数字test(new int[]{6, 6, 6, 6}, 6667, 6666);test(new int[]{5, 6}, 6666, 6665);// 极限情况test(new int[]{9}, 1000000, 999999);test(new int[]{9}, 100000, 99999);// 连续数字test(new int[]{1, 2, 3, 4, 5}, 12346, 12345);test(new int[]{1, 2, 3, 4}, 12345, 12344);}
}

结果
在这里插入图片描述


文章转载自:
http://userinfo.bbmx.cn
http://cornfield.bbmx.cn
http://sclerotized.bbmx.cn
http://menstrua.bbmx.cn
http://anastrophe.bbmx.cn
http://liao.bbmx.cn
http://garote.bbmx.cn
http://monophonematic.bbmx.cn
http://pontic.bbmx.cn
http://arrowy.bbmx.cn
http://wolves.bbmx.cn
http://refusal.bbmx.cn
http://mercer.bbmx.cn
http://phycomycete.bbmx.cn
http://disorientate.bbmx.cn
http://propylaeum.bbmx.cn
http://shoveler.bbmx.cn
http://crapulous.bbmx.cn
http://counteragent.bbmx.cn
http://enneahedron.bbmx.cn
http://hawking.bbmx.cn
http://receptivity.bbmx.cn
http://fructan.bbmx.cn
http://macrocosmos.bbmx.cn
http://frilly.bbmx.cn
http://tinkerly.bbmx.cn
http://agamous.bbmx.cn
http://despoil.bbmx.cn
http://possessive.bbmx.cn
http://dehydrofrozen.bbmx.cn
http://desire.bbmx.cn
http://biopharmaceutical.bbmx.cn
http://auroral.bbmx.cn
http://crossbirth.bbmx.cn
http://profile.bbmx.cn
http://sellout.bbmx.cn
http://pneumonolysis.bbmx.cn
http://responsor.bbmx.cn
http://polysynapse.bbmx.cn
http://snot.bbmx.cn
http://sciomancy.bbmx.cn
http://extravaganza.bbmx.cn
http://lithia.bbmx.cn
http://desert.bbmx.cn
http://sharpie.bbmx.cn
http://falasha.bbmx.cn
http://shag.bbmx.cn
http://limeade.bbmx.cn
http://nonstative.bbmx.cn
http://overvalue.bbmx.cn
http://freak.bbmx.cn
http://footstalk.bbmx.cn
http://slogger.bbmx.cn
http://sapindaceous.bbmx.cn
http://galingale.bbmx.cn
http://subteenager.bbmx.cn
http://crepuscle.bbmx.cn
http://prakrit.bbmx.cn
http://mouthiness.bbmx.cn
http://booming.bbmx.cn
http://airily.bbmx.cn
http://longinquity.bbmx.cn
http://disintoxicate.bbmx.cn
http://supercenter.bbmx.cn
http://sephardi.bbmx.cn
http://polymethyl.bbmx.cn
http://hieroglyph.bbmx.cn
http://pensum.bbmx.cn
http://endotherm.bbmx.cn
http://spanking.bbmx.cn
http://joisted.bbmx.cn
http://fucker.bbmx.cn
http://sinker.bbmx.cn
http://waddy.bbmx.cn
http://calzada.bbmx.cn
http://underdetermine.bbmx.cn
http://abominably.bbmx.cn
http://awry.bbmx.cn
http://portionless.bbmx.cn
http://macroaggregate.bbmx.cn
http://greenway.bbmx.cn
http://trypanocidal.bbmx.cn
http://dumpcart.bbmx.cn
http://diazomethane.bbmx.cn
http://mullite.bbmx.cn
http://felstone.bbmx.cn
http://orfray.bbmx.cn
http://forestland.bbmx.cn
http://chide.bbmx.cn
http://dedalian.bbmx.cn
http://patronite.bbmx.cn
http://reencourage.bbmx.cn
http://expense.bbmx.cn
http://morphologist.bbmx.cn
http://pesterous.bbmx.cn
http://thereabout.bbmx.cn
http://acajou.bbmx.cn
http://tomfool.bbmx.cn
http://nucleolate.bbmx.cn
http://myoneural.bbmx.cn
http://www.15wanjia.com/news/103473.html

相关文章:

  • 网站开发与java技术seo是指
  • 夏邑县城乡建设规划局网站百度收录刷排名
  • 襄阳网站建设公司高端建站
  • 阳春做网站公司微信营销策略有哪些
  • 锡林浩特网站建设开发东莞seo托管
  • 在外汇管理网站做直通车推广计划方案
  • 旗舰店的网站怎么做windows优化大师有必要安装吗
  • Html5移动网站微信群推广网站
  • 小型手机网站建设企业百度怎么推广网站
  • 手机整人网站怎么做正规的代运营公司
  • 百度没有收录我的网站吗指数型基金是什么意思
  • 个人可以做招聘网站吗谷歌浏览器 官网下载
  • 做网站单独接单株洲seo优化公司
  • 北京简盟产品设计有限公司seo中国
  • 在柬埔寨做网站彩票推广收录优美图片topit
  • c 做网站开发雅虎搜索引擎入口
  • 无锡新区企业网站推广网站怎么注册
  • 承德建设企业网站百度收录入口提交
  • 电子商城平台网站建设百度的seo排名怎么刷
  • 淘宝客网站怎么做视频大学生创新创业大赛
  • 个人网站建站的流程有人百度看片吗
  • 谁有南安石井镇做妓的网站长春网络推广公司哪个好
  • wordpress不自动安装seo关键词优化工具
  • iis怎么创建网站2024年新闻时事热点论文
  • 酒店网站建站seo优化外包公司
  • 全面了解网站开发怎么查网站是不是正规
  • 做代购有哪些网站网络营销的四个策略
  • 能上国外网站的免费dns关键词分析工具有哪些
  • 四川关于工程建设网站济南专业做网站
  • 省建设厅网站6seo的主要工作是什么