
Java
伊安Yann
这个作者很懒,什么都没留下…
展开
-
leetcode-cn 题库 算法部分 7 整数反转 (简单)
public class Solution { public int reverse(int x) { int y = 0; Boolean pm; if ((x == (-2 << 30)) || (x == ((2 << 30) - 1)) || x == 0) { return 0; /...原创 2018-12-20 11:56:41 · 206 阅读 · 0 评论 -
leetcode-cn 题库 算法部分 1 两数之和 (简单)
class Solution { public int[] twoSum(int[] nums, int target) { for(int j=0;j<nums.length-1;j++){ for(int i=j+1;i<nums.length;i++){ if(nums[j]+nums[...原创 2018-12-20 12:01:43 · 369 阅读 · 1 评论 -
leetcode-cn 题库 算法部分 9 回文数 (简单)
class Solution { public boolean isPalindrome(int x) { if (x < 0){ return false; }else if (x==0){ return true; }else{ String numberSt...原创 2018-12-20 13:47:21 · 211 阅读 · 0 评论 -
leetcode-cn 题库 算法部分 14 最长公共前缀 (简单)
比较慢的一个解答class Solution { public String longestCommonPrefix(String[] strs) { if (strs.length == 0) return ""; if (strs.length == 1) return strs[0]; for (String str : strs...原创 2018-12-20 15:57:54 · 135 阅读 · 0 评论 -
leetcode-cn 题库 算法部分 20 有效的括号 (简单)
非常慢的一个解法,优点可能只有好理解这一点class Solution { public boolean isValid(String s) { while (s.contains("()") || s.contains("[]") || s.contains("{}")) { s = s.replace("()",""); ...原创 2018-12-20 16:42:52 · 223 阅读 · 0 评论