Posts

Showing posts from November, 2022

Week 11

Image
 Today I did another leetcode problem. Like last week I found a similar problem to one I've done in class but with a different language but instead of mips this time it is in C++. I'm starting to think my 240 teacher was making us do these problems on purpose haha... anyway, the problem this time is called valid parenthesis or matching brackets is what my 240 teacher called it. I knew the basic rundown of the problem and tried to code it. But to give a brief rundown we are checking if all brackets "("  or "{"  or "[" are closed correctly. Fortunately, I was able to directly translate the code for the most part, so we can see the tiny differences between c++ and java.  We see in the two pictures below that c++ looks a little different. In java we see the stack as new stack but in C++ #include stack and we dont need to new. In C++ the string as treated a char arrays so we dont need to do charAt in C++ they already are characters and in this respect i...

Week 10

Image
 This week I found an interesting problem that was exactly like a problem I did in my class this semester, csc 230, but instead of mips I did it in java. The problem is fizzbuzz where you take a number and if the number is a multiple of 3 print fizz and it its a multiple of 5 print buzz and if its a multiple of both print fizzbuzz. There are two method one(first one) is the one that was in a video where I discovered the problem and the second one is me doing it the way I thought of. The problem was pretty easy but the way it did intrigued me because It was different than mine his felt much more clever than mine. What he does is creates variable fizz and buzz so when fizz equals 3 and buzz equals 5 we reset and add to the arraylist but its cool that he does this by using variables to keep track of the fizz and buzz. So fizz for the first 10 will look like this 0,1,2,0,1,2,0,1,2,0,1 for buzz its 0,1,2,3,4,0,1,2,3,4,0 at all zeros after the first zero will add the respective word....

Week 9

Image
 Today I looked at some interesting videos of some leetcode videos, which use problems that show up at coding interviews. I watched a guy who was prepping for interviews by running through these problems and talking about them. First Video was about locating islands. (pic of the instructions below) So hopefully you can see how the first input has only one island because all the ones are surrounded by zeros. It's kinda hard to see at first but it helped when he points out why in the video. He talks about the problem and comes up with a pretty straightforward solution. He says he will use a breadth first search(BFS), which I've done a bit of research on before in my week 6 of last years blog. Breadth first search when used on binary search trees takes a node and searches all of its nodes, so I can see how it can apply to this problem. Breadth first search will take one island(1) and search all the 1s connected, which is an island, so when it can't find anymore it means there ...