mirror of
				https://github.com/krahets/hello-algo.git
				synced 2025-11-04 06:07:20 +08:00 
			
		
		
		
	fix: Some Ruby code (#1231)
* fix: ruby code block - chapter computational complexity * fix: ruby code - chapter array and linkedlist
This commit is contained in:
		@ -45,8 +45,8 @@ end
 | 
			
		||||
### 删除索引 index 处的元素 ###
 | 
			
		||||
def remove(nums, index)
 | 
			
		||||
  # 把索引 index 之后的所有元素向前移动一位
 | 
			
		||||
  for i in index...nums.length
 | 
			
		||||
    nums[i] = nums[i + 1] || 0
 | 
			
		||||
  for i in index...(nums.length - 1)
 | 
			
		||||
    nums[i] = nums[i + 1]
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -195,7 +195,7 @@
 | 
			
		||||
        a = a + 1   # 1 ns
 | 
			
		||||
        a = a * 2   # 10 ns
 | 
			
		||||
        # 循环 n 次
 | 
			
		||||
        (n...0).each do # 1 ns
 | 
			
		||||
        (0...n).each do # 1 ns
 | 
			
		||||
            puts 0      # 5 ns
 | 
			
		||||
        end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user