Ruby solution, several variants of sliding window.
Leetcode: 976. Largest Perimeter Triangle.\n\n\nIdea is in sorting input array. And sliding window of 3 elements from biggest to smallest elements. If in this w
##### Leetcode: 976. Largest Perimeter Triangle.\n\n\nIdea is in sorting input array. And sliding window of 3 elements from biggest to smallest elements. If in this window biggest element is less then sum of middle and small one - this means it is largest perimeter in this array, because it is already the biggest elements that granted by required criteria. \n\nRuby code:\n```Ruby\n# Leetcode: 976. Largest Perimeter Triangle.\n# https://leetcode.com/problems/largest-perimeter-triangle/\n# Runtime: 88 ms, faster than 33.33% of Ruby online submissions for Largest Perimeter Triangle.\n# Memory Usage: 13.8 MB, less than 25.00% of Ruby online submissions for Largest Perimeter Triangle.\n# @param {Integer[]} a\n# @return {Integer}\ndef largest_perimeter(a)\n  a.sort.reverse.each_cons(3).each{|(x,y,z)| \n      return x+y+z if y+z > x\n  }\n 0\nend\n# Leetcode: 976. Largest Perimeter Triangle.\n# https://leetcode.com/problems/largest-perimeter-triangle/\n# Runtime: 116 ms, faster than 22.22% of Ruby online submissions for Largest Perimeter Triangle.\n# Memory Usage: 13.9 MB, less than 25.00% of Ruby online submissions for Largest Perimeter Triangle.\n# @param {Integer[]} a\n# @return {Integer}\ndef largest_perimeter(a)\n  z = a.sort.reverse\n  (2...z.size).each do |i|\n      return z[i-2]+z[i-1]+z[i] if z[i-2] < z[i-1] + z[i]\n  end\n  0\nend\n# Leetcode: 976. Largest Perimeter Triangle.\n# https://leetcode.com/problems/largest-perimeter-triangle/\n# Runtime: 176 ms, faster than 11.11% of Ruby online submissions for Largest Perimeter Triangle.\n# Memory Usage: 12 MB, less than 25.00% of Ruby online submissions for Largest Perimeter Triangle.\n# @param {Integer[]} a\n# @return {Integer}\ndef largest_perimeter(z)\n  z.sort_by!{|x| -x}\n  (2...z.size).each do |i|\n      return z[i-2]+z[i-1]+z[i] if z[i-2] < z[i-1] + z[i]\n  end\n  0\nend\n# Leetcode: 976. Largest Perimeter Triangle.\n# https://leetcode.com/problems/largest-perimeter-triangle/\n# Runtime: 124 ms, faster than 11.11% of Ruby online submissions for Largest Perimeter Triangle.\n# Memory Usage: 11.9 MB, less than 25.00% of Ruby online submissions for Largest Perimeter Triangle.\n# @param {Integer[]} a\n# @return {Integer}\ndef largest_perimeter(z)\n  z.sort!\n  bigest, middle, smallest = z.size-1, z.size-2, z.size-3;\n  while smallest >= 0\n     return z[bigest] + z[middle] + z[smallest] if z[bigest] < z[middle] + z[smallest]\n      bigest -= 1; middle -= 1; smallest -= 1;\n  end\n  0\nend\n```
['Sliding Window', 'Ruby']