Finding smallest value in an array most efficiently

后端 未结 13 1704
慢半拍i
慢半拍i 2020-11-29 07:02

There are N values in the array, and one of them is the smallest value. How can I find the smallest value most efficiently?

13条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-29 07:39

    //find the min in an array list of #s
    $array = array(45,545,134,6735,545,23,434);
    
    $smallest = $array[0];
    for($i=1; $i

提交回复
热议问题