Max In Linked List

Time limit: 5000ms
Memory limit: 256mb

Description:
Given a linked list L of N positive integers. Please Find out the maximum value in L.

-------------------------Copy the following code, complete it and submit-------------------------


/*
I, <Your Full Name>, am submitting the assignment for
an individual project.
I declare that the assignment here submitted is original except for
source material explicitly acknowledged, the piece of work, or a part
of the piece of work has not been submitted for more than one purpose
(i.e. to satisfy the requirements in two different courses) without
declaration. I also acknowledge that I am aware of University policy
and regulations on honesty in academic work, and of the disciplinary
guidelines and procedures applicable to breaches of such policy and
regulations, as contained in the University website
http://www.cuhk.edu.hk/policy/academichonesty/.
It is also understood that assignments without a properly signed
declaration by the student concerned will not be graded by the
teacher(s).
*/

#include <stdlib.h>
#include <stdio.h>

typedef struct node Node;
struct node{
    int v;
    Node *next;
    Node *prev;
};

typedef struct linked_list List;
struct linked_list {
    Node *head;
    Node *tail;
};

Node *allocate_node()
{
    return (Node *)malloc(sizeof(struct node));
}

List *allocate_linked_list()
{
    return (List *)malloc(sizeof(struct linked_list));
}

List *init_list(int num)
{
    //initilize the linked list
    List *L = allocate_linked_list();
    L->head = allocate_node();
    L->tail = allocate_node();

    L->head->v = 0;
    L->head->next = L->tail;
    L->head->prev = NULL;
    L->tail->v = 0;
    L->tail->next = NULL;
    L->tail->prev = L->head;

    int i = 0;
    for (i = 0; i < num; i++)
    {
        Node *node = allocate_node();
        scanf("%d", &(node->v));

        node->next = L->head->next;
        node->next->prev = node;
        L->head->next = node;
        node->prev = L->head;
    }

    return L;
}

void destory_list(List *L)
{
    Node *curr = L->head->next;

    while (curr != L->tail)
    {
        Node *next = curr->next;
        free(curr);
        curr = next;
    }

    free(L->head);
    free(L->tail);
    free(L);
    return ;
}

int find_max(List *L)
{
    // write down your code here
}

int main()
{
    int list_num = 0;
    scanf("%d", &list_num);

    List *L = init_list(list_num);
    int max = find_max(L);

    printf("%d\n", max);
    destory_list(L);

    return 0;
}

-------------------------------------------End of Code-------------------------------------------

Input:
First line contains an integer N > 0;
The second line is the values of  N positive integers;
Output:
The maximum value among the N integers

Sample Input 1:
6
6 5 3 8 7 9
Sample Output 1:
9

Sample Input 2:
8
23 30 10 44 55 18 24 35
Sample Output 2:
55
Submit