Tree left view binary tree

giving last test case as the run error , please tell me what is error in my code

@vikashkmr519,
here is the corrected code https://ide.codingblocks.com/s/169239

Since you are not using buffered reader in case the queue isn’t empty and the input string is finished. It will throw a run time error. For that use .hasNextInt() to check. If the next input is not an int, it will break and return the root node as it would mean the input is over.

ok but i m not able to underStand the work of hasNextInt() function, can you please explain me it in a little detail with some example,…Thankyou

@vikashkmr519,
hasNext function returns true if and only if this scanner’s next token is a valid Int value. In this case incase the next input is " " or something else, it will break and prevent runtime errors

ok i understood it , Thankyou very much sir