摘要:
CD48 打印两个有序链表的公共部分 /* 归并 */ public class CD48_1 { public static class ListNode { public int val; public ListNode next = null; public ListNode(int val) 阅读全文
摘要:
CD5 设计一个有 getMin 功能的栈 /* * 维护一个最小栈minStack * dataStack每压入一个数, minStack也压入一个当前状态的最小值 */ public class CD5_1 { public static class Solution { public Stac 阅读全文
摘要:
JZ42 连续子数组的最大和 /* 贪心 */ public class JZ42_1 { public static int FindGreatestSumOfSubArray(int[] array) { int sum = 0, res = Integer.MIN_VALUE; for (in 阅读全文
摘要:
JZ58 左旋转字符串 /* 模拟 */ public class JZ58_1 { public static String LeftRotateString(String str, int n) { if (str.length() == 0) return ""; n %= str.lengt 阅读全文
摘要:
JZ66 构建乘积数组 /* 暴力 */ public class JZ66_1 { public static int[] multiply(int[] A) { int[] res = new int[A.length]; Arrays.fill(res, 1); for (int i = 0; 阅读全文
摘要:
JZ53 数字在升序数组中出现的次数⭐ 1 /* 二分左边界 */ 2 public class JZ53_1 3 { 4 public static int GetNumberOfK(int[] nums, int k) 5 { 6 int left = 0, right = nums.lengt 阅读全文
摘要:
JZ29 顺时针打印矩阵 1 /* 模拟 */ 2 public class JZ29_1 3 { 4 public static ArrayList<Integer> printMatrix(int[][] matrix) 5 { 6 ArrayList<Integer> res = new Ar 阅读全文