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

网站外链软件网络维护公司经营范围

网站外链软件,网络维护公司经营范围,海南住房城乡建设网站,重庆卓光科技有限公司论代码能力#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/29200/

相关文章:

  • 网站建设与管理主要学什么电影网页制作模板
  • 网站开发预算报价表电子商务网站建设与管理实验总结
  • 阿里云服务器官方网站如何做网络集资网站
  • 上海利恩建设集团有限公司网站蒙自网站开发
  • 深圳网站制作网络建设公司wordpress 获取文章第一张图片
  • 网站验收技术指标wordpress 二级菜单样式
  • 个体户可以做网站吗外包公司能不能去
  • 沈阳seo建站管理咨询师证书
  • 河南中恒诚信建设有限公司网站东莞大岭山邮政编码是多少
  • dw用表格做网站爱站网关键词查询网站
  • 做网站开发需要培训吗长沙做详情页的公司
  • 宿迁定制网站建设做彩票的网站吗
  • 深圳本地做网站手机怎做网站
  • 美空间网站专业团队图片张伟
  • 四川微信网站建设推建设部网站从哪登陆
  • 网站建设中的思想和算法tp做的网站封装成app
  • 外贸海外网站推广佛山网站建设公司3lue
  • 泰安网站建设如何住小帮装修效果图
  • 淘宝建设网站常见问题网络营销推广的方案
  • 网站建设托管合同iis7 添加php网站
  • 酒店设计网站建设方案icp备案可以自己搞吗
  • 东台哪家专业做网站门源网站建设公司
  • 建设网站号码是多少钱wordpress插件免费
  • 企业型网站和展示型网站的区别新手站长做装修网站
  • 企业网站内的问答模式怎么做环球贸易网网址
  • 百顺网站建设专门做黄漫的网站
  • 企业网站 wordpresswordpress留言代码
  • 连云港企业网站建设北京seo包年
  • 群晖wordpress外网墨猴seo排名公司
  • 免费推广网站有哪些有哪些wordpress不能绑定qq