摘要:
class MinStack { Stack<Integer> data; Stack<Integer> helper; /** initialize your data structure here. */ public MinStack() { data = new Stack<Integer> 阅读全文
摘要:
public static int[][] direction = new int[][]{{0,-1},{0,1},{1,0},{-1,0}}; public boolean exist(char[][] board, String word) { //dfs int m = board.leng 阅读全文
摘要:
public int minArray(int[] numbers) { //二分法 int n = numbers.length; int i = 0 , j = n -1; while(i < j) { int mid = i + ((j-i) >> 1); if(numbers[mid] > 阅读全文
摘要:
public boolean findNumberIn2DArray(int[][] matrix, int target) { int m = matrix.length; if(0 == m || null == matrix)return false; int n = matrix[0].le 阅读全文
摘要:
直接dp public int respace(String[] dictionary, String sentence) { int n = sentence.length(); if(0==n)return 0; int[] dp = new int[n+1]; for(int i = 1 ; 阅读全文
摘要:
public int minSubArrayLen(int s, int[] nums) { if( 0 == nums.length || null == nums) { return 0; } int l = 0 ; int r = 0; int result = Integer.MAX_VAL 阅读全文
摘要:
public ListNode removeNthFromEnd(ListNode head, int n) { ListNode slow = head; ListNode fast = head; //快指针先走n-1步 int i = 1; while(i <= n) { fast = fas 阅读全文