Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
stack.isEmpty() vs. stack.empty()

Adrian Adewunmi

Feb 8, 2024

Hi,

Referring to Problem 1's (Balanced Parentheses) solution - line 16, which method is more appropriate for testing for an empty stack - isEmpty() or empty()?

if (stack.isEmpty()) { return false; } OR if (stack.empty()) { return false; }

0

0

Comments
Comments
A
APOORVA CHIKARAa year ago

isEmpty is a more description way which tells the function will return a boolean value. It is more descriptive way to define methods

On this page