
com_github_leetcode.list_node.rb Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of leetcode-in-all Show documentation
Show all versions of leetcode-in-all Show documentation
104 LeetCode algorithm problem solutions
# Definition for singly-linked list.
class ListNode
attr_accessor :val, :next
def initialize(x = 0, _next = nil)
@val = x
@next = _next
end
def to_a
result = []
current = self
while current
result << current.val
current = current.next
end
result
end
end
© 2015 - 2025 Weber Informatics LLC | Privacy Policy