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

免费空间网站php搜索框html代码

免费空间网站php,搜索框html代码,温州论坛吧,二手交易网站建设目标论代码能力#xff1a; 给出两个 非空 的链表用来表示两个非负的整数。其中#xff0c;它们各自的位数是按照 逆序 的方式存储的#xff0c;并且它们的每个节点只能存储 一位 数字。 如果#xff0c;我们将这两个数相加起来#xff0c;则会返回一个新的链表来表示它们的…论代码能力 给出两个 非空 的链表用来表示两个非负的整数。其中它们各自的位数是按照 逆序 的方式存储的并且它们的每个节点只能存储 一位 数字。 如果我们将这两个数相加起来则会返回一个新的链表来表示它们的和。 您可以假设除了数字 0 之外这两个数都不会以 0 开头。 示例 输入(2 - 4 - 3) (5 - 6 - 4) 输出7 - 0 - 8 原因342 465 807主方法为addTwoNumbers 自己最初的解题代码 public class Test {public static void main(String[] args) throws InterruptedException { // 输入(2 - 4 - 3) (5 - 6 - 4) // 输出7 - 0 - 8 // 原因342 465 807 // [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1] // [5,6,4]ListNode aNode initNode(new int[]{5});ListNode bNode initNode(new int[]{5});ListNode cNode addTwoNumbers(aNode, bNode);System.out.println(JSONObject.toJSONString(cNode));}public static ListNode initNode(int [] arr) {ListNode head new ListNode(arr[0]);ListNode node head;for(int i1;iarr.length;i) {ListNode tNode new ListNode(arr[i]);node.next tNode;node node.next;}return head;}public static class ListNode {int val;ListNode next;public ListNode(int val) {this.val val;}}public static ListNode addTwoNumbers(ListNode l1, ListNode l2) {ListInteger arr1 new ArrayListInteger();ListInteger arr2 new ArrayListInteger();ListNode t1 l1;ListNode t2 l2;while (t1!null) {arr1.add(t1.val);t1 t1.next;}while (t2!null) {arr2.add(t2.val);t2 t2.next;}ListInteger arr3 null;arr3 getResultList(arr1.size() arr2.size()?arr1:arr2, arr1.size() arr2.size()?arr2:arr1);ListNode head new ListNode(arr3.get(0));ListNode node head;for(int i1;iarr3.size();i) {ListNode tNode new ListNode(arr3.get(i));node.next tNode;node node.next;}return head;}public static ListInteger getResultList(ListInteger longList, ListInteger shortList) {ListInteger arr3 new ArrayListInteger();int jinJi 0;for(int i0;ilongList.size();i) {int a longList.get(i);int b0;if(ishortList.size()) {bshortList.get(i);}int count ab jinJi;if(count9) {jinJi 1;}else {jinJi 0;}arr3.add(count % 10);}if(jinJi ! 0) {arr3.add(jinJi);}return arr3;}}参照标准答案重写的代码 public class Test {public static void main(String[] args) throws InterruptedException { // 输入(2 - 4 - 3) (5 - 6 - 4) // 输出7 - 0 - 8 // 原因342 465 807 // [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1] // [5,6,4]ListNode aNode initNode(new int[]{5});ListNode bNode initNode(new int[]{5});ListNode cNode addTwoNumbers(aNode, bNode);System.out.println(JSONObject.toJSONString(cNode));}public static ListNode initNode(int [] arr) {ListNode head new ListNode(arr[0]);ListNode node head;for(int i1;iarr.length;i) {ListNode tNode new ListNode(arr[i]);node.next tNode;node node.next;}return head;}public static class ListNode {int val;ListNode next;public ListNode(int val) {this.val val;}}public static ListNode addTwoNumbers(ListNode l1, ListNode l2) {//哑节点ListNode yaNode new ListNode(0);ListNode head yaNode;int jinJi 0;int benJi 0;while (l1!null || l2!null) {int temp (l1 null?0:l1.val) (l2null?0:l2.val) jinJi;jinJi temp9?1:0;benJi temp % 10;ListNode node new ListNode(benJi);head.next node;head head.next;if(l1 ! null) {l1 l1.next;}if(l2 ! null) {l2 l2.next;}}if(jinJi ! 0) {ListNode node new ListNode(jinJi);head.next node;}return yaNode.next;} 部分思路按照人类解题加法超过9进级的思路是类似的但是局部进行了优化不用借助ArrayList直接使用链表遍历即可 减少了内存占用并且代码更加的简洁易懂不易出错。继续努力吧
http://www.yutouwan.com/news/212404/

相关文章:

  • 网站建设前途无锡网站搜索优化
  • 行业网站建设的书哪家公司做的网站好
  • 微网站开发案例重庆 网站 建设
  • asp黑网站源码苏州手机社区网站建设
  • 要加强县门户网站的建设管理百度竞价排名的利与弊
  • 高校工会网站建设工程建设方案
  • 赢了网站怎么做的北京网站建设+招聘信息
  • wordpress 上传网站吗如何查看网站的空间大小
  • 网站开发范本网站制作公司资质
  • 建网站 绑定域名 网址怎样做网站吸引人
  • 莆田外贸建站关键词优化举例
  • 如何在局域网中做网站镇江发布的最新消息
  • 网站推广开户设置wordpress文章图片不显示
  • icp备案查询站长工具团员电子档案查询系统
  • 易企网络网站建设湖南 网站备案
  • 免费建网站 手机网站图片生成二维码在线制作
  • 商务网站建设平台企业网站建设与推广多少钱
  • 河西做网站的公司网站建设相关的博客有哪些
  • 权威做网站的公司微信扫码登记小程序
  • 汽修网站怎么做冯耀宗seo视频教程
  • 网站维护是不是很难做今天济南刚刚发生的新闻
  • 图片网站收录tradekey外贸平台官网
  • 建设银行北京分行网站邯郸建设局网站资质申报
  • 网站建设新闻中心呼和浩特网站推广公司
  • 免费cms建站系统有哪些学院网站设计模板
  • 福州seo推广优化杭州百度人工优化
  • 工信部网站 备案时间dtcms网站开发教程
  • 做电子商务网站免费的行情网站ifind是
  • 宁波市住房与城乡建设部网站如何零基础做网站
  • 网页设计公司建网站网站设计苏州公司网站建设找哪家