Home > Back-end > Singly linked lists the minimum to delete
Singly linked lists the minimum to delete
Time:10-04
Recently, just learning Java, teacher assigned a topic, the smallest element of request to delete the lead node singly linked lists, struggling with delete all the smallest element should be how to implement, have no idea, bosses to give directions
CodePudding user response:
Traverse again to find out the minimum first, traverse again found that equals the minimum element node deletion
CodePudding user response:
Define a variable before traversal of min=Integer. Max, when traversing a node if the node value is less than min, save the node, after the traversal will save node to change the value of its next node values and then remove the next node