Short simple Ruby
\ndef array_nesting(nums)\n  seen_nums = Hash.new\n  result = 0\n  (0 ... nums.length).each do |i|\n\n    count = 0\n    n = nums[i]\n    while !seen_nums[n]\n 
```\ndef array_nesting(nums)\n  seen_nums = Hash.new\n  result = 0\n  (0 ... nums.length).each do |i|\n\n    count = 0\n    n = nums[i]\n    while !seen_nums[n]\n      seen_nums[n] = 1\n      count += 1\n      n = nums[n]\n    end\n    result = [result, count].max\n  end\n  result\nend\n```
[]