[Solved] Whats the point of traversing through the linked list to get a value, I could get it directly right?


In your case, there is no downside to directly get the value, but in many other cases you will use some function to create the new nodes and more often than not you will only have one pointer that directly point to a node (usually the head).
So while here it is not wrong to directly grab the value, in most cases, there isn’t the option to grab the value and you will need to traverse if you want to get the values

solved Whats the point of traversing through the linked list to get a value, I could get it directly right?