mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-14 17:32:35 +08:00

I made the code shorter and less prone to mistakes by removing the "size" variable altogether from the LinkedList class. I found that after each push/pop operation, changing the value of size did make the code more efficient, but made it more prone to mistakes. So, for empty stack, a simple "head == null" was enough, which has been incorporated.