V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
twig
V2EX  ›  Elixir 编程语言

LeetCode: 153. Find Minimum in Rotated Sorted Array

  •  
  •   twig · 14 天前 · 360 次点击
    defmodule Solution do
      @spec find_min(nums :: [integer]) :: integer
      def find_min(nums) do
        [head | tail] = nums
        tail
        |> Enum.reduce_while(
          head,
          fn item, acc ->
          if item < acc do
            { :halt, item }
          else
            { :cont, acc }
          end
        end)
      end
    end
    
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2474 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 02:18 · PVG 10:18 · LAX 19:18 · JFK 22:18
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.