<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>
-
URL
<The URL Structure (path only, no root url)>
-
Method:
// O(n) 評估最糟的實際情況是 3(n-3)+3 | |
function Max3(arr){ | |
if(arr.length < 3) return undefined | |
let max3 = [arr[0], arr[1], arr[2]] | |
// 對max3進行排序 | |
if (max3[0] < max3[1]) [max3[0], max3[1]] = [max3[1], max3[0]] | |
if (max3[1] < max3[2]) [max3[1], max3[2]] = [max3[2], max3[1]] | |
if (max3[0] < max3[1]) [max3[0], max3[1]] = [max3[1], max3[0]] | |
// 朝狀迴圈比較max3是否確實為前三個最大的數 |
package main | |
import( | |
"encoding/json" | |
"io/ioutil" | |
"fmt" | |
"log" | |
"net/http" | |
"github.com/gorilla/mux" |
package main | |
import( | |
"log" | |
"net/http" | |
"github.com/gorilla/mux" | |
) | |
func get(w http.ResponseWriter, r *http.Request){ | |
w.Header().Set("Content-Type", "application/json") |