All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com_github_leetcode.list_node.rb Maven / Gradle / Ivy

There is a newer version: 1.8
Show newest version
# 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