Reverse Double Linked List in C#

This is a question that often comes up in an interview. The solution is simple, but under pressure it’s easy to get confused. To begin with, initialise three node references: Remember to point the tail to the head before we begin: Now, iterate over the nodes using current, until there are no more: Within the […]

List Comprehensions

Whenever you see this pattern to create a list of items: (values) = [] for (value) in (collection): (values).append((expression)) You can replace it with a list comprehension, which takes the form of: (values) = [ (expression) for (value) in (collection)] This: Can be replaced with: Notice how the variable used to iterate over the collection […]