App Academy W2D3
Today is about “class”
We started the day by solving Leetcode problems. Easy ones, but still hard to achieve a perfect time complexity.
First one is Valid Anagram

My thought was just to create hashes to store the character counts and then compare hashes. My solution:

Works fine with ~90% time complexity
Second one is called Max Consecutive Ones

my thought was to use nested while loops to keep track of the consecutive “ones” with a counter, and update the counter when we find a longer consecutive line of ones.
Here is my code:

Only achieved ~60% of time complexity, which means I can optimize the run time. Will put it onto my To_do_list.
After finishing these problems, we went to different break rooms on Zoom and started pair coding.
Today we had a lot of fun constructing this classes. The first two ones, “the master mind” and “battleship” was comparatively easier because they give us the spec files and being very specific about how they want us to build the app. But the third one “tic-tac-toe” was quite hard because there is not much instructions and we have to build or classes from nothing by ourselves.
All of the codes are in my github repo and I still have to fix some bugs for the last one “tic-tac-toe”.
But it’s really fun. No more data manipulations or sheer coding, we now tap into the real coding world and start to build something. Which is really cool.

New knowledge:
In ruby we have to be careful about “-”, today I came across a bug, I write something like “row.length -1”, there is a space between row.length and “-1”
Ruby just give me an error, and I just don’t know why. If I delete the space, then it works fine. For now I don’t know the theory deep inside, but will keep this in mind.
To_do_list:
- revise Leetcode problem
- debug “tic-tac-toe” project
- add multiple player to the “tic-tac-toe”