LeetCode: Weekly Contest 100

题目描述

1. LeetCode: 896. Monotonic Array 题解

遍历数组,标记升序/降序情况。当发现后面的元素与前面的标记冲突时,则返回 false, 否则返回 true

2. LeetCode: 897. Increasing Order Search Tree 题解

分治法。先分别对左/右子树做 Increasing 操作,然后将左右子树通过 root 节点连接起来。

3. LeetCode: 898. Bitwise ORs of Subarrays 题解

A[x...i], x = 0...1Bitwise ORsA[x...i-1], x=0...i-1Bitwise ORs 异或 A[i]

4. LeetCode: 899. Orderly Queue 题解

  1. 当 K == 1 时, 只能循环移动每个元素,无法改变相对位置。因此只需要获取循环移动过程中字典序最小的序列。
  2. 当 K > 1 时, 可以生成当前字符串的任意序列。因此将原字符串排序生成字典序最小的序列。