Something Like this should work.
trigger ExampleTrigger on Task (after insert) {
set<Id> leadIds = new set<Id>();
for(Task t: trigger.new){
if(t.Who.Type == 'Lead'){
leadIds.add(t.WhoId);
}
}
list<Lead> leadsToUpdate = new list<Lead>([Select Id, Name, Last_Activity_Type, (Select Id, ActivityDate, Type__c From Tasks) From Lead Where Id in : leadIds]);
//This will cycyle through all the leads
for(Lead l: leadsToUpdate){
Date latestActivity;
/*This will go through each task related to the current lead and find the
task with the latest date, and change the Last_Activity_Date__c fieild
on that lead to the type of that latest activity*/
for(Task t : l.Tasks){
if (latestActivity == null || lastestActivity < t.ActivityDate){
latestActivity = t.ActivityDate;
l.Last_Activity_Type__c = t.Type__c;
}
}
}
update leadsToUpdate;
}