MCPcopy
hub / github.com/HuberTRoy/leetCode / getKNodes

Function getKNodes

Array/ReverseNodesInk-Group.js:22–33  ·  view source on GitHub ↗
(head)

Source from the content-addressed store, hash-verified

20// 思路不难,个人感觉难点在于ListNode是在不好操作。
21var reverseKGroup = function(head, k) {
22 function getKNodes(head) {
23 let nodes = []
24 let newHead = head
25
26 //
27 while (nodes.length < k && newHead) {
28 nodes.push(newHead)
29 newHead = newHead.next
30 }
31
32 return nodes
33 }
34
35 function reverse(nodes) {
36 // 将nodes里的ListNode关系翻转

Callers 1

reverseKGroupFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected