当前位置: 首页 > 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://wiki.neutronadmin.com/news/212404/

相关文章:

  • 买机票便宜网站建设企业网站建设的意义
  • 织梦做的网站打开慢html网页模板代码下载
  • 好看的学校网站首页wordpress 轻论坛
  • 台州 做网站嘉兴市城乡规划建设局网站
  • title 芜湖网站制作wordpress文章分类插件
  • 别样网图片素材网站用html5做网站百度经验
  • 外贸型网站建设方法网络系统定级备案
  • 湖南兼职网站建设h5平台官网
  • 成都高档网站建设wordpress当前分类下所有子分类
  • 如何做网站视频外贸信息发布平台
  • 收费网站设计平面排版网站
  • 无锡网站设计多少钱大气蓝色律师网站phpcms模板
  • 精美的php个人网站源码个体网站建设
  • 网站开发构成怎么申请小程序流程
  • 渝水区城乡建设局网站江苏工信部网站备案查询
  • 内网网站建设方面政策做30个精品网站
  • 如何做新闻自动采集网站wordpress建立的博客
  • cms仿站教程网站怎么申请微博登录
  • 山西 网站建设秦皇岛手机网站制作
  • 谷搜易外贸网站建设建设政务网站
  • 学做沪江网站要多久网站备案 更改ip
  • 动易手机网站黑龙江企业信息系统
  • 酒店网站设计百度推广营销怎么做
  • 开网站空间流量怎么选择专业网站设计
  • 适合个人做的网站网站后台更新无法在网页显示
  • 网站建设技术内容企业推广
  • 苏州建站专业制作网站公司吗
  • 商城网站建设讯息怎么黑入网站
  • 做pc端网站报价小型公司网络建设方案
  • 上海杨浦区网站建设做儿童方面的网站