The AI-organized question lists I used for the past three months of OAs were basically useless, and I didn't get any repeat questions. It's the same as what people on the forum have been reporting lately: I mass-applied and got the OA instantly. But it's still the 90-minute, four-level format.
The problem gives you a batch of Parcels. Each Parcel has its own ParcelId and attributes (key, value), and there can be many differently named attributes. You then implement update, set, and get of different attributes by ParcelId under different conditions (every operation carries a timestamp). Each level has different requirements, four levels in total.
Level 1: implement simple set (overwrite if it already exists), get, and updateIfMatch (the new value can only be set if the current attribute value strictly matches the expected one).
Level 2: implement ListAttrByParcelId, where the output format has to be "attrName(val)" with the names sorted lexicographically. Then ListAttrByParcelIdWithAttrPrefix, which is roughly the previous one plus a filter on the attribute prefix (strings.HasSuffix), and you just output the result.
Level 3: every attribute now has a ttl, and both list and get have to check whether it has expired. A ttl of 0 means it never expires. Update and set now need to be able to set the ttl. Update cannot update an attribute that has already expired, but it can set one that has not expired to ttl 0 (never expires).
Level 4: I didn't get to it...
Okay, now a pile of pitfalls + tips.
-
This one is infuriating: every function you need to implement in Level 1 and Level 2 takes a timestamp parameter that is completely unused, and it is very misleading. I wrote things in a complicated way at first because I thought I was doing something like LeetCode 981 (maybe levels 3 and 4 use it), and from very early on I was agonizing over whether the operations' timestamps are monotonically increasing, whether I need to keep values sorted on insert, and so on. Then I looked again and realized that setting again just overwrites. Level 3 also doesn't turn into LeetCode 981, because each attribute under a parcel id only has a single value (but you do need to carry the last timestamp and the ttl along with it).
-
Running the tests is really slow, you wait a full minute.
-
You can pick any language. If you pick Go it is very easy to step on a landmine (the language adaptation feels really weird, and I don't know what this problem was translated from. It makes a simple problem complicated). Each method is wrapped in several layers and it's set up like polymorphism. First they give you an interface (file1), then they specifically make a struct called abstract (file2), and finally they give you an almost completely empty Impl struct (file3). I'm not very experienced with this, and I agonized for ages over where to actually implement things. In the end I defined every func in file3, copy-pasted everything into file3, and changed the receiver to the impl one before the tests would run. By then close to a third of the time was gone.
-
The problems are not very hard. For scoring, they don't require the optimal solution; if you can brute force it and pass the tests, that's enough, so allocate your time sensibly. If you're comfortable hand-rolling business code you'll be fine, but if your coding skill is limited to LeetCode, you should practice some easy OOD problems.
-
And fellow pet owners, you absolutely must keep a quiet environment! I've had terrible luck lately. There was renovation going on outside during the day, so I picked the middle of the night to do the OA, and my dog thought I was dead for not sleeping and kept banging on the door like crazy (during the day when I close the door and work from home or do interviews she never does this, aaaaah). Also, the whole time you have to share your screen, and the camera and mic both have to be on.
Last of all, I didn't finish debugging the Level 3 tests, so only some passed (tests: 25/35). Score: 410/600. I'm probably toast. I finished in the middle of the night and came straight here to write this up.
Discussion
Loading comments…