摘要:
问题: 给定一个数组,求连续元素之和在给定范围[lower, upper]之间的,连续idx为(i~j)元素组个数。 Note: A naive algorithm of O(n2) is trivial. You MUST do better than that. Example: Input: 阅读全文
摘要:
问题: 给定一个数组,从左向右遍历数组每一个元素, 对每一个元素,记录,其右边比他小的元素个数到res数组中。 求res数组。 Example: Input: [5,2,6,1] Output: [2,1,1,0] Explanation: To the right of 5 there are 2 阅读全文
摘要:
问题: 给定一组带有评分rating的士兵序列。 求从中挑出3个士兵 i, j, k (i<j<k)为一个小组,使得第 i, j, k 名士兵的 rating递增or递减。 这样的小组有多少个。 Example 1: Input: rating = [2,5,3,4,1] Output: 3 Exp 阅读全文