twig

LeetCode: 153. Find Minimum in Rotated Sorted Array

  •  
  •   twig · May 3, 2024 · 1604 views
    This topic created in 740 days ago, the information mentioned may be changed or developed.
    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
    
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1186 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 41ms · UTC 23:32 · PVG 07:32 · LAX 16:32 · JFK 19:32
    ♥ Do have faith in what you're doing.