Time complexity: O(n)
Space complexity: O(1)
Runtime: 1 ms, faster than 96.51% of Java online submissions for Can Place Flowers. Memory Usage: 45.2 MB, less than 83.36% of Java online submissions for Can Place Flowers.