- 博客(8)
- 收藏
- 关注
原创 2.28 leetcode 删除排序数组中的重复项(双指针)
myimport java.util.*;class Tt { public static void main(String[] args) { //int[] nums = {1, 1, 2}; int[] nums = {0,0,1,1,1,2,2,3,3,4}; removeDuplicates(nums); }/* public static void sop(Object obj) { System.out.println(obj);
2021-02-28 21:32:15 68 2
原创 2.25 leetcode 合并两个有序链表
myimport java.util.*;class Tttt{ public static void main(String[] args) { int[] a1 = {1,2,4}; int[] a2 = {1,3,4}; get(a1, a2); } public static LinkedList get(int[] a1,int[] a2) { List<Integer> link1 = Ints.asList(a1); //Lin
2021-02-25 10:17:56 63 1
原创 2.17 leetcode 罗马数字转整数
参考import java.util.*;class Solution { public int romanToInt(String s) { int sum = 0; int preNum = getValue(s.charAt(0)); for(int i = 1;i < s.length(); i ++) { int num = getValue(s.charAt(i)); if(pre
2021-02-19 15:27:38 53
转载 Java中char, char[], String, int, Integer, BigInteger常用转换关系总结
关于Java中char, char[], String, int, Integer, BigInteger常用转换关系总结
2021-02-19 15:26:05 216
原创 2.18 leetcode 最长公共前缀
标准class Solution { public String longestCommonPrefix(String[] strs) { if (strs == null || strs.length == 0) { return ""; } int length = strs[0].length(); int count = strs.length; for (int i = 0; i &l
2021-02-18 23:22:12 57
原创 2.16 LeetCode 回数判断
class reverse { public static void main(String[] args) { System.out.println( isPalindrome(-456)); } public static boolean isPalindrome(int x) { int flag = 1; if (x<0) { flag = 0; return 1 == flag; } Str
2021-02-16 10:25:05 60
原创 2.15 LeetCode整数反转
#标准class Solution { public int reverse(int x) { int ans = 0; while (x != 0) { int pop = x % 10; if (ans > Integer.MAX_VALUE / 10 || (ans == Integer.MAX_VALUE / 10 && pop > 7)) retu
2021-02-15 21:50:15 153 1
原创 2.15 LeetCode两数之和
class Solution { public int[] twoSum(int[] nums, int target) { if(nums.length < 2){ return new int[0]; } int[] rearr = new int[2]; //查询元素 for(int i = 0; i < nums.length; i++){ for(in
2021-02-15 10:58:31 52
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人