![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
水题一遍过
小白苦学编程
这个作者很懒,什么都没留下…
展开
-
leetCode 9 palindrome-number题解
题目地址第一次一遍过,超100%,打卡纪念,无难度,关键是开longclass Solution { public boolean isPalindrome(int x) { if(x < 0) return false; long re = 0; long mirror = x; while(mirror > 0) ...原创 2019-05-04 17:54:51 · 115 阅读 · 0 评论 -
LeetCode 13. Roman to Integer 题解
题目链接打表public int romanToInt(String s) { int[] m = new int[128]; m['M'] = 1000; m['D'] = 500; m['C'] = 100; m['L'] = 50; m['X'] = 10; m['V'] = 5; m['I'] = 1; int ans = 0...原创 2019-05-06 17:39:01 · 132 阅读 · 0 评论 -
leetcode 12. Integer to Roman题解
题目链接打表public String intToRoman(int num) { String [] s ; s = new String[] {"M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"}; int[] a = new int[]{1000,900...原创 2019-05-06 17:42:15 · 109 阅读 · 0 评论 -
LeetCode 8. String to Integer (atoi) 题解
题目地址读题即可,错可能因为超过int返回0,开long搞定class Solution { public int myAtoi(String str) { long ans = 0; int sign = 0; boolean valid = true; for(int i = 0; i < str.length(); i ++) { ...原创 2019-05-06 18:00:22 · 108 阅读 · 0 评论 -
leetcode 100. Same Tree 题解
题目地址深度优先 DFSclass Solution { public boolean isSameTree(TreeNode p, TreeNode q) { if(p == null) return q == null; if(q == null) return false; return p.val == q.val &&a...原创 2019-05-07 15:59:59 · 102 阅读 · 0 评论