This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Solution { | |
public int longestPalindrome(String s) { | |
int m = 0; | |
int n = 0; | |
Map<Character, Integer> cache = new HashMap<Character, Integer>(); | |
char[] sc = s.toCharArray(); | |
for(char c : sc){ | |
if(cache.get(c) != null){ | |
cache.put(c, cache.get(c) + 1); | |
} else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class QuickSort { | |
public static void main(String[] args) { | |
int[] x = { 9, 2, 4, 7, 3, 7, 10 }; | |
System.out.println(Arrays.toString(x)); | |
int low = 0; | |
int high = x.length - 1; | |
quickSort(x, low, high); | |
System.out.println(Arrays.toString(x)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Solution { | |
public String longestPalindrome(String s) { | |
String T = preProcess(s); | |
int n = T.length(); | |
int[] p = new int[n]; | |
int center = 0, right = 0; | |
for (int i = 1; i < n - 1; i++) { | |
int j = 2 * center - i; //j and i are symmetric around center | |
p[i] = (right > i) ? Math.min(right - i, p[j]) : 0; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public int longestPalindrome(String s) { | |
int n=s.length(); | |
boolean[][] pal=new boolean[n][n]; | |
//pal[i][j] 表示s[i...j]是否是回文串 | |
int maxLen=0; | |
for (int i=0;i<n;i++){ // i作为终点 | |
int j=i; //j作为起点 | |
while (j>=0){ | |
if (s.charAt(j)==s.charAt(i)&&(i-j<2||pal[j+1][i-1])){ | |
pal[j][i]=true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ls | sed "s:^:`pwd`/: " |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find . -type f -size +200M -print0 | xargs -0 du -h | sort -nr |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tcpdump -XplAs0 -xxvvv -i any |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//https://leetcode.com/problems/combination-sum/ | |
//模版思路 解法 | |
public class Solution { | |
public static List<List<Integer>> result = new ArrayList<List<Integer>>(); | |
public static int[] path = new int[100]; | |
public static int len = 0; | |
public List<List<Integer>> combinationSum(int[] candidates, int target) { | |
result.clear(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//https://leetcode.com/problems/combination-sum/ | |
public class Solution { | |
public List<List<Integer>> combinationSum(int[] candidates, int target) { | |
List<List<Integer>> result = new ArrayList<List<Integer>>(); | |
if (candidates == null || candidates.length == 0) | |
return result; | |
ArrayList<Integer> current = new ArrayList<Integer>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//https://leetcode.com/problems/combination-sum-iii/ | |
public class Solution { | |
//ans | |
public static List<List<Integer>> result = new ArrayList<List<Integer>>(); | |
public static List<List<Integer>> combinationSum3(int k, int n) { | |
result.clear(); | |
List<Integer> curr = new ArrayList<Integer>(); | |