From 09da1ec2166892e809a63f791c19e6d3a085129e Mon Sep 17 00:00:00 2001 From: openset Date: Sun, 12 May 2019 15:04:22 +0800 Subject: [PATCH] Add: new --- README.md | 32 +++++---- .../README.md | 62 +++++++++++++++++ .../longest-duplicate-substring/README.md | 41 ++++++++++++ .../README.md | 2 +- .../partition-array-for-maximum-sum/README.md | 34 ++++++++++ problems/robot-bounded-in-circle/README.md | 67 +++++++++++++++++++ 6 files changed, 223 insertions(+), 15 deletions(-) create mode 100644 problems/flower-planting-with-no-adjacent/README.md create mode 100644 problems/longest-duplicate-substring/README.md create mode 100644 problems/partition-array-for-maximum-sum/README.md create mode 100644 problems/robot-bounded-in-circle/README.md diff --git a/README.md b/README.md index b41fc6a76..6571bb293 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,10 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1044 | [Longest Duplicate Substring](https://leetcode.com/problems/longest-duplicate-substring "最长重复子串") | [Go](https://github.com/openset/leetcode/tree/master/problems/longest-duplicate-substring) | Hard | +| 1043 | [Partition Array for Maximum Sum](https://leetcode.com/problems/partition-array-for-maximum-sum "分隔数组以得到最大和") | [Go](https://github.com/openset/leetcode/tree/master/problems/partition-array-for-maximum-sum) | Medium | +| 1042 | [Flower Planting With No Adjacent](https://leetcode.com/problems/flower-planting-with-no-adjacent "不邻接植花") | [Go](https://github.com/openset/leetcode/tree/master/problems/flower-planting-with-no-adjacent) | Easy | +| 1041 | [Robot Bounded In Circle](https://leetcode.com/problems/robot-bounded-in-circle "困于环中的机器人") | [Go](https://github.com/openset/leetcode/tree/master/problems/robot-bounded-in-circle) | Easy | | 1040 | [Moving Stones Until Consecutive II](https://leetcode.com/problems/moving-stones-until-consecutive-ii "移动石子直到连续 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/moving-stones-until-consecutive-ii) | Medium | | 1039 | [Minimum Score Triangulation of Polygon](https://leetcode.com/problems/minimum-score-triangulation-of-polygon "多边形三角剖分的最低得分") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-score-triangulation-of-polygon) | Medium | | 1038 | [Binary Search Tree to Greater Sum Tree](https://leetcode.com/problems/binary-search-tree-to-greater-sum-tree "从二叉搜索树到更大和树") | [Go](https://github.com/openset/leetcode/tree/master/problems/binary-search-tree-to-greater-sum-tree) | Medium | @@ -322,7 +326,7 @@ LeetCode Problems' Solutions | 775 | [Global and Local Inversions](https://leetcode.com/problems/global-and-local-inversions "全局倒置与局部倒置") | [Go](https://github.com/openset/leetcode/tree/master/problems/global-and-local-inversions) | Medium | | 774 | [Minimize Max Distance to Gas Station](https://leetcode.com/problems/minimize-max-distance-to-gas-station) 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/minimize-max-distance-to-gas-station) | Hard | | 773 | [Sliding Puzzle](https://leetcode.com/problems/sliding-puzzle "滑动谜题") | [Go](https://github.com/openset/leetcode/tree/master/problems/sliding-puzzle) | Hard | -| 772 | [Basic Calculator III](https://leetcode.com/problems/basic-calculator-iii) 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/basic-calculator-iii) | Hard | +| 772 | [Basic Calculator III](https://leetcode.com/problems/basic-calculator-iii "基本计算器 III") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/basic-calculator-iii) | Hard | | 771 | [Jewels and Stones](https://leetcode.com/problems/jewels-and-stones "宝石与石头") | [Go](https://github.com/openset/leetcode/tree/master/problems/jewels-and-stones) | Easy | | 770 | [Basic Calculator IV](https://leetcode.com/problems/basic-calculator-iv "基本计算器 IV") | [Go](https://github.com/openset/leetcode/tree/master/problems/basic-calculator-iv) | Hard | | 769 | [Max Chunks To Make Sorted](https://leetcode.com/problems/max-chunks-to-make-sorted "最多能完成排序的块") | [Go](https://github.com/openset/leetcode/tree/master/problems/max-chunks-to-make-sorted) | Medium | @@ -334,17 +338,17 @@ LeetCode Problems' Solutions | 763 | [Partition Labels](https://leetcode.com/problems/partition-labels "划分字母区间") | [Go](https://github.com/openset/leetcode/tree/master/problems/partition-labels) | Medium | | 762 | [Prime Number of Set Bits in Binary Representation](https://leetcode.com/problems/prime-number-of-set-bits-in-binary-representation "二进制表示中质数个计算置位") | [Go](https://github.com/openset/leetcode/tree/master/problems/prime-number-of-set-bits-in-binary-representation) | Easy | | 761 | [Special Binary String](https://leetcode.com/problems/special-binary-string "特殊的二进制序列") | [Go](https://github.com/openset/leetcode/tree/master/problems/special-binary-string) | Hard | -| 760 | [Find Anagram Mappings](https://leetcode.com/problems/find-anagram-mappings) 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/find-anagram-mappings) | Easy | -| 759 | [Employee Free Time](https://leetcode.com/problems/employee-free-time) 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/employee-free-time) | Hard | -| 758 | [Bold Words in String](https://leetcode.com/problems/bold-words-in-string) 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/bold-words-in-string) | Easy | +| 760 | [Find Anagram Mappings](https://leetcode.com/problems/find-anagram-mappings "找出变位映射") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/find-anagram-mappings) | Easy | +| 759 | [Employee Free Time](https://leetcode.com/problems/employee-free-time "员工空闲时间") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/employee-free-time) | Hard | +| 758 | [Bold Words in String](https://leetcode.com/problems/bold-words-in-string "字符串中的加粗单词") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/bold-words-in-string) | Easy | | 757 | [Set Intersection Size At Least Two](https://leetcode.com/problems/set-intersection-size-at-least-two " 设置交集大小至少为2") | [Go](https://github.com/openset/leetcode/tree/master/problems/set-intersection-size-at-least-two) | Hard | | 756 | [Pyramid Transition Matrix](https://leetcode.com/problems/pyramid-transition-matrix "金字塔转换矩阵") | [Go](https://github.com/openset/leetcode/tree/master/problems/pyramid-transition-matrix) | Medium | -| 755 | [Pour Water](https://leetcode.com/problems/pour-water) 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/pour-water) | Medium | +| 755 | [Pour Water](https://leetcode.com/problems/pour-water "倒水") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/pour-water) | Medium | | 754 | [Reach a Number](https://leetcode.com/problems/reach-a-number "到达终点数字") | [Go](https://github.com/openset/leetcode/tree/master/problems/reach-a-number) | Easy | | 753 | [Cracking the Safe](https://leetcode.com/problems/cracking-the-safe "破解保险箱") | [Go](https://github.com/openset/leetcode/tree/master/problems/cracking-the-safe) | Hard | | 752 | [Open the Lock](https://leetcode.com/problems/open-the-lock "打开转盘锁") | [Go](https://github.com/openset/leetcode/tree/master/problems/open-the-lock) | Medium | -| 751 | [IP to CIDR](https://leetcode.com/problems/ip-to-cidr) 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/ip-to-cidr) | Easy | -| 750 | [Number Of Corner Rectangles](https://leetcode.com/problems/number-of-corner-rectangles) 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/number-of-corner-rectangles) | Medium | +| 751 | [IP to CIDR](https://leetcode.com/problems/ip-to-cidr "IP 到 CIDR") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/ip-to-cidr) | Easy | +| 750 | [Number Of Corner Rectangles](https://leetcode.com/problems/number-of-corner-rectangles "角矩形的数量") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/number-of-corner-rectangles) | Medium | | 749 | [Contain Virus](https://leetcode.com/problems/contain-virus "隔离病毒") | [Go](https://github.com/openset/leetcode/tree/master/problems/contain-virus) | Hard | | 748 | [Shortest Completing Word](https://leetcode.com/problems/shortest-completing-word "最短完整词") | [Go](https://github.com/openset/leetcode/tree/master/problems/shortest-completing-word) | Easy | | 747 | [Largest Number At Least Twice of Others](https://leetcode.com/problems/largest-number-at-least-twice-of-others "至少是其他数字两倍的最大数") | [Go](https://github.com/openset/leetcode/tree/master/problems/largest-number-at-least-twice-of-others) | Easy | @@ -383,16 +387,16 @@ LeetCode Problems' Solutions | 714 | [Best Time to Buy and Sell Stock with Transaction Fee](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-transaction-fee "买卖股票的最佳时机含手续费") | [Go](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock-with-transaction-fee) | Medium | | 713 | [Subarray Product Less Than K](https://leetcode.com/problems/subarray-product-less-than-k "乘积小于K的子数组") | [Go](https://github.com/openset/leetcode/tree/master/problems/subarray-product-less-than-k) | Medium | | 712 | [Minimum ASCII Delete Sum for Two Strings](https://leetcode.com/problems/minimum-ascii-delete-sum-for-two-strings "两个字符串的最小ASCII删除和") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-ascii-delete-sum-for-two-strings) | Medium | -| 711 | [Number of Distinct Islands II](https://leetcode.com/problems/number-of-distinct-islands-ii) 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/number-of-distinct-islands-ii) | Hard | +| 711 | [Number of Distinct Islands II](https://leetcode.com/problems/number-of-distinct-islands-ii "不同岛屿的数量 II") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/number-of-distinct-islands-ii) | Hard | | 710 | [Random Pick with Blacklist](https://leetcode.com/problems/random-pick-with-blacklist "黑名单中的随机数") | [Go](https://github.com/openset/leetcode/tree/master/problems/random-pick-with-blacklist) | Hard | | 709 | [To Lower Case](https://leetcode.com/problems/to-lower-case "转换成小写字母") | [Go](https://github.com/openset/leetcode/tree/master/problems/to-lower-case) | Easy | -| 708 | [Insert into a Cyclic Sorted List](https://leetcode.com/problems/insert-into-a-cyclic-sorted-list) 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/insert-into-a-cyclic-sorted-list) | Medium | +| 708 | [Insert into a Cyclic Sorted List](https://leetcode.com/problems/insert-into-a-cyclic-sorted-list "循环有序列表的插入") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/insert-into-a-cyclic-sorted-list) | Medium | | 707 | [Design Linked List](https://leetcode.com/problems/design-linked-list "设计链表") | [Go](https://github.com/openset/leetcode/tree/master/problems/design-linked-list) | Easy | | 706 | [Design HashMap](https://leetcode.com/problems/design-hashmap "设计哈希映射") | [Go](https://github.com/openset/leetcode/tree/master/problems/design-hashmap) | Easy | | 705 | [Design HashSet](https://leetcode.com/problems/design-hashset "设计哈希集合") | [Go](https://github.com/openset/leetcode/tree/master/problems/design-hashset) | Easy | | 704 | [Binary Search](https://leetcode.com/problems/binary-search "二分查找") | [Go](https://github.com/openset/leetcode/tree/master/problems/binary-search) | Easy | | 703 | [Kth Largest Element in a Stream](https://leetcode.com/problems/kth-largest-element-in-a-stream "数据流中的第K大元素") | [Go](https://github.com/openset/leetcode/tree/master/problems/kth-largest-element-in-a-stream) | Easy | -| 702 | [Search in a Sorted Array of Unknown Size](https://leetcode.com/problems/search-in-a-sorted-array-of-unknown-size) 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/search-in-a-sorted-array-of-unknown-size) | Medium | +| 702 | [Search in a Sorted Array of Unknown Size](https://leetcode.com/problems/search-in-a-sorted-array-of-unknown-size "搜索长度未知的有序数组") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/search-in-a-sorted-array-of-unknown-size) | Medium | | 701 | [Insert into a Binary Search Tree](https://leetcode.com/problems/insert-into-a-binary-search-tree "二叉搜索树中的插入操作") | [Go](https://github.com/openset/leetcode/tree/master/problems/insert-into-a-binary-search-tree) | Medium | | 700 | [Search in a Binary Search Tree](https://leetcode.com/problems/search-in-a-binary-search-tree "二叉搜索树中的搜索") | [Go](https://github.com/openset/leetcode/tree/master/problems/search-in-a-binary-search-tree) | Easy | | 699 | [Falling Squares](https://leetcode.com/problems/falling-squares "掉落的方块") | [Go](https://github.com/openset/leetcode/tree/master/problems/falling-squares) | Hard | @@ -400,7 +404,7 @@ LeetCode Problems' Solutions | 697 | [Degree of an Array](https://leetcode.com/problems/degree-of-an-array "数组的度") | [Go](https://github.com/openset/leetcode/tree/master/problems/degree-of-an-array) | Easy | | 696 | [Count Binary Substrings](https://leetcode.com/problems/count-binary-substrings "计数二进制子串") | [Go](https://github.com/openset/leetcode/tree/master/problems/count-binary-substrings) | Easy | | 695 | [Max Area of Island](https://leetcode.com/problems/max-area-of-island "岛屿的最大面积") | [Go](https://github.com/openset/leetcode/tree/master/problems/max-area-of-island) | Medium | -| 694 | [Number of Distinct Islands](https://leetcode.com/problems/number-of-distinct-islands) 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/number-of-distinct-islands) | Medium | +| 694 | [Number of Distinct Islands](https://leetcode.com/problems/number-of-distinct-islands "不同岛屿的数量") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/number-of-distinct-islands) | Medium | | 693 | [Binary Number with Alternating Bits](https://leetcode.com/problems/binary-number-with-alternating-bits "交替位二进制数") | [Go](https://github.com/openset/leetcode/tree/master/problems/binary-number-with-alternating-bits) | Easy | | 692 | [Top K Frequent Words](https://leetcode.com/problems/top-k-frequent-words "前K个高频单词") | [Go](https://github.com/openset/leetcode/tree/master/problems/top-k-frequent-words) | Medium | | 691 | [Stickers to Spell Word](https://leetcode.com/problems/stickers-to-spell-word "贴纸拼词") | [Go](https://github.com/openset/leetcode/tree/master/problems/stickers-to-spell-word) | Hard | @@ -452,18 +456,18 @@ LeetCode Problems' Solutions | 645 | [Set Mismatch](https://leetcode.com/problems/set-mismatch "错误的集合") | [Go](https://github.com/openset/leetcode/tree/master/problems/set-mismatch) | Easy | | 644 | [Maximum Average Subarray II](https://leetcode.com/problems/maximum-average-subarray-ii "最大平均子段和 II") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-average-subarray-ii) | Hard | | 643 | [Maximum Average Subarray I](https://leetcode.com/problems/maximum-average-subarray-i "子数组最大平均数 I") | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-average-subarray-i) | Easy | -| 642 | [Design Search Autocomplete System](https://leetcode.com/problems/design-search-autocomplete-system) 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/design-search-autocomplete-system) | Hard | +| 642 | [Design Search Autocomplete System](https://leetcode.com/problems/design-search-autocomplete-system "设计搜索自动补全系统") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/design-search-autocomplete-system) | Hard | | 641 | [Design Circular Deque](https://leetcode.com/problems/design-circular-deque "设计循环双端队列") | [Go](https://github.com/openset/leetcode/tree/master/problems/design-circular-deque) | Medium | | 640 | [Solve the Equation](https://leetcode.com/problems/solve-the-equation "求解方程") | [Go](https://github.com/openset/leetcode/tree/master/problems/solve-the-equation) | Medium | | 639 | [Decode Ways II](https://leetcode.com/problems/decode-ways-ii "解码方法 2") | [Go](https://github.com/openset/leetcode/tree/master/problems/decode-ways-ii) | Hard | | 638 | [Shopping Offers](https://leetcode.com/problems/shopping-offers "大礼包") | [Go](https://github.com/openset/leetcode/tree/master/problems/shopping-offers) | Medium | | 637 | [Average of Levels in Binary Tree](https://leetcode.com/problems/average-of-levels-in-binary-tree "二叉树的层平均值") | [Go](https://github.com/openset/leetcode/tree/master/problems/average-of-levels-in-binary-tree) | Easy | | 636 | [Exclusive Time of Functions](https://leetcode.com/problems/exclusive-time-of-functions "函数的独占时间") | [Go](https://github.com/openset/leetcode/tree/master/problems/exclusive-time-of-functions) | Medium | -| 635 | [Design Log Storage System](https://leetcode.com/problems/design-log-storage-system) 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/design-log-storage-system) | Medium | +| 635 | [Design Log Storage System](https://leetcode.com/problems/design-log-storage-system "设计日志存储系统") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/design-log-storage-system) | Medium | | 634 | [Find the Derangement of An Array](https://leetcode.com/problems/find-the-derangement-of-an-array "寻找数组的错位排列") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/find-the-derangement-of-an-array) | Medium | | 633 | [Sum of Square Numbers](https://leetcode.com/problems/sum-of-square-numbers "平方数之和") | [Go](https://github.com/openset/leetcode/tree/master/problems/sum-of-square-numbers) | Easy | | 632 | [Smallest Range](https://leetcode.com/problems/smallest-range "最小区间") | [Go](https://github.com/openset/leetcode/tree/master/problems/smallest-range) | Hard | -| 631 | [Design Excel Sum Formula](https://leetcode.com/problems/design-excel-sum-formula) 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/design-excel-sum-formula) | Hard | +| 631 | [Design Excel Sum Formula](https://leetcode.com/problems/design-excel-sum-formula "设计 Excel 求和公式") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/design-excel-sum-formula) | Hard | | 630 | [Course Schedule III](https://leetcode.com/problems/course-schedule-iii "课程表 III") | [Go](https://github.com/openset/leetcode/tree/master/problems/course-schedule-iii) | Hard | | 629 | [K Inverse Pairs Array](https://leetcode.com/problems/k-inverse-pairs-array "K个逆序对数组") | [Go](https://github.com/openset/leetcode/tree/master/problems/k-inverse-pairs-array) | Hard | | 628 | [Maximum Product of Three Numbers](https://leetcode.com/problems/maximum-product-of-three-numbers "三个数的最大乘积") | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-product-of-three-numbers) | Easy | diff --git a/problems/flower-planting-with-no-adjacent/README.md b/problems/flower-planting-with-no-adjacent/README.md new file mode 100644 index 000000000..49da05573 --- /dev/null +++ b/problems/flower-planting-with-no-adjacent/README.md @@ -0,0 +1,62 @@ + + + + + + + +[< Previous](https://github.com/openset/leetcode/tree/master/problems/robot-bounded-in-circle "Robot Bounded In Circle") +                 +[Next >](https://github.com/openset/leetcode/tree/master/problems/partition-array-for-maximum-sum "Partition Array for Maximum Sum") + +## 1042. Flower Planting With No Adjacent (Easy) + +

You have N gardens, labelled 1 to N.  In each garden, you want to plant one of 4 types of flowers.

+ +

paths[i] = [x, y] describes the existence of a bidirectional path from garden x to garden y.

+ +

Also, there is no garden that has more than 3 paths coming into or leaving it.

+ +

Your task is to choose a flower type for each garden such that, for any two gardens connected by a path, they have different types of flowers.

+ +

Return any such a choice as an array answer, where answer[i] is the type of flower planted in the (i+1)-th garden.  The flower types are denoted 1, 2, 3, or 4.  It is guaranteed an answer exists.

+ +

 

+ +
+

Example 1:

+ +
+Input: N = 3, paths = [[1,2],[2,3],[3,1]]
+Output: [1,2,3]
+
+ +
+

Example 2:

+ +
+Input: N = 4, paths = [[1,2],[3,4]]
+Output: [1,2,1,2]
+
+ +
+

Example 3:

+ +
+Input: N = 4, paths = [[1,2],[2,3],[3,4],[4,1],[1,3],[2,4]]
+Output: [1,2,3,4]
+
+ +

 

+ +

Note:

+ +
    +
  • 1 <= N <= 10000
  • +
  • 0 <= paths.size <= 20000
  • +
  • No garden has 4 or more paths coming into or leaving it.
  • +
  • It is guaranteed an answer exists.
  • +
+
+
+
diff --git a/problems/longest-duplicate-substring/README.md b/problems/longest-duplicate-substring/README.md new file mode 100644 index 000000000..2bfb4f352 --- /dev/null +++ b/problems/longest-duplicate-substring/README.md @@ -0,0 +1,41 @@ + + + + + + + +[< Previous](https://github.com/openset/leetcode/tree/master/problems/partition-array-for-maximum-sum "Partition Array for Maximum Sum") +                 +Next > + +## 1044. Longest Duplicate Substring (Hard) + +

Given a string S, consider all duplicated substrings: (contiguous) substrings of S that occur 2 or more times.  (The occurrences may overlap.)

+ +

Return any duplicated substring that has the longest possible length.  (If S does not have a duplicated substring, the answer is "".)

+ +

 

+ +

Example 1:

+ +
+Input: "banana"
+Output: "ana"
+
+ +

Example 2:

+ +
+Input: "abcd"
+Output: ""
+
+ +

 

+ +

Note:

+ +
    +
  1. 2 <= S.length <= 10^5
  2. +
  3. S consists of lowercase English letters.
  4. +
diff --git a/problems/moving-stones-until-consecutive-ii/README.md b/problems/moving-stones-until-consecutive-ii/README.md index ad5898b30..d12e89d51 100644 --- a/problems/moving-stones-until-consecutive-ii/README.md +++ b/problems/moving-stones-until-consecutive-ii/README.md @@ -7,7 +7,7 @@ [< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-score-triangulation-of-polygon "Minimum Score Triangulation of Polygon")                  -Next > +[Next >](https://github.com/openset/leetcode/tree/master/problems/robot-bounded-in-circle "Robot Bounded In Circle") ## 1040. Moving Stones Until Consecutive II (Medium) diff --git a/problems/partition-array-for-maximum-sum/README.md b/problems/partition-array-for-maximum-sum/README.md new file mode 100644 index 000000000..aba135cd8 --- /dev/null +++ b/problems/partition-array-for-maximum-sum/README.md @@ -0,0 +1,34 @@ + + + + + + + +[< Previous](https://github.com/openset/leetcode/tree/master/problems/flower-planting-with-no-adjacent "Flower Planting With No Adjacent") +                 +[Next >](https://github.com/openset/leetcode/tree/master/problems/longest-duplicate-substring "Longest Duplicate Substring") + +## 1043. Partition Array for Maximum Sum (Medium) + +

Given an integer array A, you partition the array into (contiguous) subarrays of length at most K.  After partitioning, each subarray has their values changed to become the maximum value of that subarray.

+ +

Return the largest sum of the given array after partitioning.

+ +

 

+ +

Example 1:

+ +
+Input: A = [1,15,7,9,2,5,10], K = 3
+Output: 84
+Explanation: A becomes [15,15,15,9,10,10,10]
+ +

 

+ +

Note:

+ +
    +
  1. 1 <= K <= A.length <= 500
  2. +
  3. 0 <= A[i] <= 10^6
  4. +
diff --git a/problems/robot-bounded-in-circle/README.md b/problems/robot-bounded-in-circle/README.md new file mode 100644 index 000000000..ea385a22a --- /dev/null +++ b/problems/robot-bounded-in-circle/README.md @@ -0,0 +1,67 @@ + + + + + + + +[< Previous](https://github.com/openset/leetcode/tree/master/problems/moving-stones-until-consecutive-ii "Moving Stones Until Consecutive II") +                 +[Next >](https://github.com/openset/leetcode/tree/master/problems/flower-planting-with-no-adjacent "Flower Planting With No Adjacent") + +## 1041. Robot Bounded In Circle (Easy) + +

On an infinite plane, a robot initially stands at (0, 0) and faces north.  The robot can receive one of three instructions:

+ + + +

The robot performs the instructions given in order, and repeats them forever.

+ +

Return true if and only if there exists a circle in the plane such that the robot never leaves the circle.

+ +

 

+ +

Example 1:

+ +
+Input: "GGLLGG"
+Output: true
+Explanation: 
+The robot moves from (0,0) to (0,2), turns 180 degrees, and then returns to (0,0).
+When repeating these instructions, the robot remains in the circle of radius 2 centered at the origin.
+
+ +
+

Example 2:

+ +
+Input: "GG"
+Output: false
+Explanation: 
+The robot moves north indefinetely.
+
+ +
+

Example 3:

+ +
+Input: "GL"
+Output: true
+Explanation: 
+The robot moves from (0, 0) -> (0, 1) -> (-1, 1) -> (-1, 0) -> (0, 0) -> ...
+
+
+ +

 

+ +

Note:

+ +
    +
  1. 1 <= instructions.length <= 100
  2. +
  3. instructions[i] is in {'G', 'L', 'R'}
  4. +
+