摘要:
@ 超级丑数 Super Ugly Number A super ugly number is a positive integer whose prime factors are in the array primes. Given an integer n and an array of int 阅读全文
摘要:
Last Stone Weight 最后一块石头的重量 We have a collection of stone , each stone has a positive integer weight. Each turn, we choose the two heaviest stones and 阅读全文
摘要:
二叉树中的列表 Linked List in Binary Tree7 一颗以root为根的二叉树,和一个head 为首节点的链表。如果在二叉树中存在一个一直向下的路径,并且每一个节点的值都对应head为首节点的链表的值,那么就返回true,否则返回 false head = [4,2,8] roo 阅读全文
摘要:
@ 将 x 减到 0 的最小操作数 Minimum Operations to Reduce X to Zero 给定一个整数数组nums和一个整数x。每一次操作时,应当删除nums的最left和最right的元素,然后从x中减去该元素的值。 如果可以将x正好减到0,返回最小操作数;否则 返回-1 阅读全文
摘要:
Get K small Num 最小的k个数 输入int[],找出最小的k个数。 输入:arr = [3,2,1], k = 2 输出:[1,2] 或者 [2,1] 思路 可以通过大顶堆,来保持k个数,来得到最小的k个数 public int[] getLeastNumbers(int[] arr, 阅读全文