【LeetCode】Remove Duplicates from Sorted List &&Climbing Stairs

来源:互联网 发布:修改rdp端口 编辑:程序博客网 时间:2024/06/07 00:31
/** * Definition for singly-linked list. * public class ListNode { *     int val; *     ListNode next; *     ListNode(int x) { *         val = x; *         next = null; *     } * } */public class Solution {   public ListNode deleteDuplicates(ListNode head){if (head == null)return null;ListNode curNode = head;while (curNode.next != null) {if (curNode.val == curNode.next.val) {curNode.next = curNode.next.next;} elsecurNode = curNode.next;}return head;}}


public class Solution {    public int climbStairs(int n) {        int[] a=new int[n+1];        a[1]=1;        a[0]=1;        for(int i=2;i<=n;i++)        a[i]=a[i-1]+a[i-2];        return a[n];    }}


0 0
原创粉丝点击