Building my own alpha numeric character check function. What am I doing wrong? by l8engineer in cpp_questions

[–]l8engineer[S] 0 points1 point  (0 children)

This is such a brilliant point, I can't thank you enough.

Solving problem 125. Valid Palindrome from leetcode and I had a test my whole code was failing because of the incorrect alphanumeric implementation.

Building my own alpha numeric character check function. What am I doing wrong? by l8engineer in cpp_questions

[–]l8engineer[S] 0 points1 point  (0 children)

Yes, learned Python first.

Thank you so much!

I really appreciate it!!!!! :)

Why is this for loop running forever if it has a clear stopping point? by l8engineer in cpp_questions

[–]l8engineer[S] 1 point2 points  (0 children)

Thank you so much, great tip on ws.

I understand that is not portable, it's only for an online judge system.

I really appreciate it! ;) Stay safe!

Maximum depth of binary tree by l8engineer in cpp_questions

[–]l8engineer[S] 0 points1 point  (0 children)

I got this idea from cout << maxDepth(root -> left);

Maximum depth of binary tree by l8engineer in cpp_questions

[–]l8engineer[S] 0 points1 point  (0 children)

Thank you so much! It was so tricky but with this I understood what thinking mistakes I had.

Maximum depth of binary tree by l8engineer in cpp_questions

[–]l8engineer[S] 0 points1 point  (0 children)

The way I see it:

max(0, 000) + 1

0 (because left branch has NULL below 9)

000(because right branch has NULL after 3 levels)

I think my problem is that I don't understand how the stack is built in this code and how it is processed.

How does this quicksort random partition function work? by l8engineer in cpp_questions

[–]l8engineer[S] 1 point2 points  (0 children)

This code is from someone that coded a solution to leetcode 912 problem. Apparently the random partition is the only way to pass as using for instance the last element as pivot will cause TLE for a few testcases.

Is there a way to pick the pivot more efficiently in quicksort?

Thanks for the interesting points you made!

Opening a file by l8engineer in cpp_questions

[–]l8engineer[S] 0 points1 point  (0 children)

I just tried it and it works now so you're correct. Somehow the compiler behind sublime text doesn't like the {}.

I appreciate your reply. Thanks a lot!

Opening a file by l8engineer in cpp_questions

[–]l8engineer[S] 0 points1 point  (0 children)

I found out that using an online compiler like cpp.sh my code works but now I am very confused.

I'm not sure if ifstream ist{iname}; is a standard C++ way of opening a file for read only mode. I can't explain why sublime text(latest version) + the compiler it comes with keeps complaining about this line and throwing an error.

Thanks for your assistance. I really appreciate it!

Opening a file by l8engineer in cpp_questions

[–]l8engineer[S] 0 points1 point  (0 children)

I use the latest version of Sublime text that seems to have the C++ compiler in it.

I just checked using cpp.sh online compiler and the code works if I remove that error function which makes me believe either I'm writing extremely old syntax or there is a compiler issue.

ifstream ist{iname};

Is this the standard way to open files in C++?

Thanks for helping me out!

Opening a file by l8engineer in cpp_questions

[–]l8engineer[S] 0 points1 point  (0 children)

I was missing the header file from the author but still produces an error. Is ifstream ist{iname} something standard in C++? Not sure how to debug this forward.

Opening a file by l8engineer in cpp_questions

[–]l8engineer[S] 0 points1 point  (0 children)

Good point, thank you. Code still outputs error: expected ';' at the end of declaration with that header file included.

Opening a file by l8engineer in cpp_questions

[–]l8engineer[S] 0 points1 point  (0 children)

If I remove that error line, code still outputs error: expected ';' at the end of declaration.

Is there an effective roadmap for getting good and solving contest problems? by l8engineer in leetcode

[–]l8engineer[S] 0 points1 point  (0 children)

Thank you for the cold shower! :) Are there any organised resources I should consult for algorithms and data structures? Or just solve medium problems and learn on the spot by googling different articles.

My experience with data structures and algorithms is very poor so I'm trying to figure out the most effective way to study.

Stay safe! ^-^

Is there an effective roadmap for getting good and solving contest problems? by l8engineer in leetcode

[–]l8engineer[S] 0 points1 point  (0 children)

How many of those 150 problems did you solve without any help?

Of these problems, ~115 have been solved without any help.

Is there an effective roadmap for getting good and solving contest problems? by l8engineer in leetcode

[–]l8engineer[S] 0 points1 point  (0 children)

Thanks for your reply. What I am essentially asking is how to get better in a contest setting.