Is possible
public static void main(String[] ss) { System.out.println(isPossible(1,4,5, 14)); } static boolean isPossible(int a, int b, int c, int d) { if (a == c && b == d) return true; if (a + b > c && a + b > d) return false; return isPossible(a + b, b, c, d) || isPossible(a, b + a, c, d); }remove dup nodes
static Node removeDup(Node root) { Set<Integer> set = new HashSet<>(); Node pre = null, rt = root; while (root != null) { if (set.contains(root.val)) { pre.next = root.next; }else { set.add(root.val); pre = root; } root = root.next; } return rt; }https://www.1point3acres.com/bbs/forum.php?mod=viewthread&tid=455584&extra=page%3D2%26filter%3Dsortid%26sortid%3D311%26searchoption%5B3046%5D%5Bvalue%5D%3D17%26searchoption%5B3046%5D%5Btype%5D%3Dradio%26sortid%3D311%26orderby%3Ddateline
https://www.1point3acres.com/bbs/forum.php?mod=viewthread&tid=453482&extra=page%3D2%26filter%3Dsortid%26sortid%3D311%26searchoption%5B3046%5D%5Bvalue%5D%3D17%26searchoption%5B3046%5D%5Btype%5D%3Dradio%26sortid%3D311%26orderby%3Ddateline
No comments:
Post a Comment