![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
编程练习
文章平均质量分 69
Mr_zhaoz
若要世界因我变,我要先随世界变
展开
-
反向链表解题方案
反向链表解题方案class Solution { public ListNode reverseList(ListNode head) { // 方法一:逐个将旧链表的节点插入到新链表 // ListNode new_head = null; //新链表的尾节点 // while(head!=null){ // L...原创 2020-03-02 23:57:05 · 404 阅读 · 0 评论 -
Leetcode练习-两个数字相加(Add two numbers)
题目要求:给你两个非空链表,表示两个非负整数。数字以相反的顺序存储,每个节点包含一个数字。添加这两个数字并将其作为链接列表返回。您可以假定这两个数字不包含任何前导零,除了数字0本身。例输入:(2→4→3)+(5→6→4) 输出: 7→0→8 说明: 342 + 465 = 807。代码如下:单链表类:public class ListNod原创 2018-02-07 17:04:47 · 515 阅读 · 0 评论 -
LeetCode练习-翻转数字(Reverse Integer)
Given a 32-bit signed integer, reverse digits of an integer.Example 1:Input: 123Output: 321Example 2:Input: -123Output: -321Example 3:Input: 120Output: 21Note:Assume we are dealing with an envi...原创 2018-03-20 09:48:51 · 477 阅读 · 0 评论 -
LeetCode练习-回文测试(Palindrome Number)
描述:确定整数是否是回文。并且没有额外的空间。我的测试:在整数翻转的基础上进行修改 public boolean isPalindrome(int x) { int befx=x; int rev = 0; if(x<0||(x%10==0&&x!=0)){ return false; } while (x != 0) { if (rev !=...原创 2018-03-20 10:45:49 · 450 阅读 · 0 评论