Class Solution
java.lang.Object
g0701_0800.s0725_split_linked_list_in_parts.Solution
725 - Split Linked List in Parts.<p>Medium</p>
<p>Given the <code>head</code> of a singly linked list and an integer <code>k</code>, split the linked list into <code>k</code> consecutive linked list parts.</p>
<p>The length of each part should be as equal as possible: no two parts should have a size differing by more than one. This may lead to some parts being null.</p>
<p>The parts should be in the order of occurrence in the input list, and parts occurring earlier should always have a size greater than or equal to parts occurring later.</p>
<p>Return <em>an array of the</em> <code>k</code> <em>parts</em>.</p>
<p><strong>Example 1:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2021/06/13/split1-lc.jpg" alt="" /></p>
<p><strong>Input:</strong> head = [1,2,3], k = 5</p>
<p><strong>Output:</strong> [[1],[2],[3],[],[]]</p>
<p><strong>Explanation:</strong></p>
<p>The first element output[0] has output[0].val = 1, output[0].next = null.</p>
<p>The last element output[4] is null, but its string representation as a ListNode is [].</p>
<p><strong>Example 2:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2021/06/13/split2-lc.jpg" alt="" /></p>
<p><strong>Input:</strong> head = [1,2,3,4,5,6,7,8,9,10], k = 3</p>
<p><strong>Output:</strong> [[1,2,3,4],[5,6,7],[8,9,10]]</p>
<p><strong>Explanation:</strong></p>
<p>The input has been split into consecutive parts with size difference at most 1, and earlier parts are a larger size than the later parts.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li>The number of nodes in the list is in the range <code>[0, 1000]</code>.</li>
<li><code>0 <= Node.val <= 1000</code></li>
<li><code>1 <= k <= 50</code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
splitListToParts
-