I've just taken the OA of shopee
There are 2 coding test in 60mins
I think they belongs to Easy difficulty according to leetcode problem difficulty
They are using Glider
First one is the easy version of https://leetcode.com/problems/valid-parentheses/ ( just '(' and')' )
An input string is valid if:
Open brackets must be closed.
Open brackets must be closed in the correct order.
But it is a little weird, that ")()" is valid, so all the close bracket is ok to be leftover.
So check stack is null after loop make it false, I failed 1/9 testcase which I've still cannot figure out what wrong. I did pass valid-parentheses with 0ms but cannot pass this one
I did check stack find if there's any open bracket being leftover.
Second one is funny sort, which can explain like:
The biggest floor in ascending order in 0th, 2th, 4th,..
The smallest ceil in descending order in 1th, 3th, 5th..
Input: a list of number
Output: a list applying funny sort
Example: 3 8 4 5 6 1 7
Output: 1 8 3 7 4 6 5
as you can see: 1 3 4 5 is in ascend order, 8 7 6 is in descend order
I solved this problem with O(n) Time Complexity and O(n) Space Complexity, in about 5 mins, I mean it's quite easy though. Then go back to messing with the first problem. I think they're finding someone solve this with O(1) Space Complexity
Note: This was the first time I took a OA. I need to write a program to solve the problem (not just a class or a function like Leetcode)