fix: adapt missing ruby style guide (#1216)

This commit is contained in:
khoaxuantu
2024-04-03 20:01:29 +07:00
committed by GitHub
parent c435d177a1
commit 043085d0ea
13 changed files with 84 additions and 84 deletions

View File

@ -17,10 +17,10 @@ end
### 将列表反序列化为链表 ###
def arr_to_linked_list(arr)
head = current = ListNode.new arr[0]
head = current = ListNode.new(arr[0])
for i in 1...arr.length
current.next = ListNode.new arr[i]
current.next = ListNode.new(arr[i])
current = current.next
end

View File

@ -37,8 +37,8 @@ def print_tree(root, prev=nil, is_right=false)
return if root.nil?
prev_str = " "
trunk = Trunk.new prev, prev_str
print_tree root.right, trunk, true
trunk = Trunk.new(prev, prev_str)
print_tree(root.right, trunk, true)
if prev.nil?
trunk.str = "———"
@ -50,9 +50,9 @@ def print_tree(root, prev=nil, is_right=false)
prev.str = prev_str
end
show_trunk trunk
show_trunk(trunk)
puts " #{root.val}"
prev.str = prev_str if prev
trunk.str = " |"
print_tree root.left, trunk, false
print_tree(root.left, trunk, false)
end