/** * @param a: an array of float numbers * @return: a float number */func MaxOfArray(a []float32) float32 { // write your code here max := a[0] for i := 1; i < len(a); i++ { if a[i] > max { max = a[i] } } return max}
public class School { /* * Declare a private attribute *name* of type string. */ // write your code here private String name; /** * Declare a setter method `setName` which expect a parameter *name*. */ // write your code here public void setName(String name) { this.name = name; } /** * Declare a getter method `getName` which expect no parameter and return * the name of this school */ // write your code here public String getName() { return this.name; }}
/** * Definition for singly-linked list. * type ListNode struct { * Val int * Next *ListNode * } *//** * @param head: the head of linked list. * @param val: An integer. * @return: a linked node or null. */func FindNode(head *ListNode, val int) *ListNode { // write your code here for head != nil { if head.Val == val{ return head } head = head.Next } return nil}
/** * Definition for singly-linked list. * type ListNode struct { * Val int * Next *ListNode * } *//** * @param head: the head of linked list. * @return: a middle node of the linked list */func MiddleNode(head *ListNode) *ListNode { // write your code here count := 0 h := head for h != nil { count++ h = h.Next } m := count / 2 if count%2 == 0 { m-- } for i := 0; i < m; i++ { head = head.Next } return head}
func MiddleNode(head *ListNode) *ListNode { // write your code here if head == nil || head.Next == nil || head.Next.Next == nil { return head } pre := head cur := head.Next.Next for cur.Next != nil && cur.Next.Next != nil { pre = pre.Next cur = cur.Next.Next } return pre.Next}
import "strconv"func StringToInteger(target string) int { // write your code here i, _ := strconv.Atoi(target) return i}