# Find largest node value of doubly linked list in swift

Swift program for Find largest node value of doubly linked list. Here problem description and other solutions.

``````import Foundation
// Swift 4 program for
// Find max value in doubly linked list

// Define class of linked list Node
{
var data: Int;
init(_ data: Int)
{
self.data = data;
self.next = nil;
self.prev = nil;
}
}
{
init()
{
self.tail = nil;
}
// Insert new node at end position
func insert(_ value: Int)
{
// Create a new node
{
self.tail = node;
return;
}
// Add node at last position
self.tail!.next = node;
node!.prev = self.tail;
self.tail = node;
}
func maximum() -> Int
{
{
return 0;
}
// Get first node of linked list
while (temp  != nil)
{
if (temp!.data > result)
{
result = temp!.data;
}
// Visit to next node
temp = temp!.next;
}
// Return maximum value
return result;
}
static func main(_ args: [String])
{
// Insert following linked list nodes
dll!.insert(14);
dll!.insert(31);
dll!.insert(12);
dll!.insert(15);
dll!.insert(11);
dll!.insert(25);
print("Maximum  :",dll!.maximum());
}
}
``Maximum  : 31``