码迷,mamicode.com
首页 > 编程语言 > 详细

每日算法练习(2020-1-27)

时间:2020-01-28 09:27:22      阅读:76      评论:0      收藏:0      [点我收藏+]

标签:code   class   image   remove   null   int   app   div   inf   

技术图片

public int removeElement(int[] nums, int val) {
        if(nums==null||nums.length==0)
        {
            return 0;
        }
        int j=0;
        for(int i=0;i<nums.length;i++)
        {
            if(nums[i]!=val)
            {
                nums[j]=nums[i];
                j++;
            }
        }
        return j;
    }

技术图片

      public class ListNode {
          int val;
          ListNode next;
          ListNode(int x) { val = x; }
     }

    class Solution {
        public ListNode swapPairs(ListNode head) {
            if(head==null||head.next==null)
            {
                return head;
            }
            ListNode next=head.next;
            head.next=swapPairs(next.next);
            next.next=head;
            return head;
        }
    }

 

每日算法练习(2020-1-27)

标签:code   class   image   remove   null   int   app   div   inf   

原文地址:https://www.cnblogs.com/qyx66/p/12237291.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!