Skip to content

Instantly share code, notes, and snippets.

public class ZipInt {
public static void main(String[] argv) {
ZipInt zi = new ZipInt();
System.out.println(zi.solution(12, 56));
System.out.println(zi.solution(56, 12));
System.out.println(zi.solution(12345, 678));
System.out.println(zi.solution(123, 67890));
System.out.println(zi.solution(10, 100));
System.out.println(zi.solution(0, 0));
System.out.println(zi.solution(2, 0));
@rayjcwu
rayjcwu / auto_liker
Last active July 23, 2021 16:53
a python script to press like on all statuses posted by target user
"""
a graph API script to press like on all statuses posted by target user
"""
import requests # Use 3rd party request module for http request.
import json
import time
"""
search for your target user name in desktop version facebook.
when you press enter, you could see URL like https://www.facebook.com/profile.php?id=##############&fref=ts for a while
class Point {
double x;
double y;
String type;
public Point() {
}
public Point(Point other) {
this(other.type, other.x, other.y);
public int uniqueLength(String str) {
char[] s = str.toCharArray();
Set<Character> showed = new HashSet<Character>();
int front = 0;
int back = 0;
int maxLen = 0;
// unique substring [back: front - 1]
while (front < s.length) {
sort(Integer[] A, Comparator <Integer>() {
@Override
public int compare(Integer a, Integer b) {
final boolean aEven = (a % 2) == 0;
final boolean bEven = (b % 2) == 0;
if ((aEven && bEven )|| (!aEven && !bEven)) {
return a - b;
} else {
return (aEven)? -1: 1;
public void evenOdd(int[] A) {
// [0: even - 1] // even
// [even: odd] // unsorted
// [odd + 1: A.length - 1] // odd
int even = 0;
int odd = A.length - 1;
while (even <= odd) {
if (A[even] % 2 == 0) {
even++;
} else {
// wrong
public int ways(int x) {
int[] ans = new int[x + 1];
for (int i = 1; i < ans.length; i++) {
if (i == 1 || i == 5 || i == 10) {
ans[i] += 1;
}
if (i - 1 > 0) {
ans[i] += ans[i - 1];
}
// without parent
public Node findCommonAncestor(Node root, Node n1, Node n2) {
if (root == null) {
return null;
} else if (root == n1 || root == n2) {
return root;
} else {
Node leftAnc = findCommonAncestor(root.left, n1, n2);
Node rightAnc = findCommonAncestor(root.right, n1, n2);
public String uniqueChar(String str) {
Set<Character> showed = new HashSet<Character>();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < str.length(); ++i) {
final char c = str.charAt(i);
if (!showed.contains(c)) {
showed.add(c);
sb.append(c);
}
@rayjcwu
rayjcwu / GuessAnagramNumber
Created March 14, 2014 05:20
find the smallest x such that x, 2x, 3x, 4x, 5x, 6x are anagram
import java.util.HashMap;
import java.util.Map;
public class GuessNumber {
public static void main(String[] argv) {
GuessNumber gn = new GuessNumber();
gn.entry();
}