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

LeetCode: 153. Find Minimum in Rotated Sorted Array

  •  
  •   twig · 17 天前 · 404 次点击
    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   ·   实用小工具   ·   1112 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 18:48 · PVG 02:48 · LAX 11:48 · JFK 14:48
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.