This is for internship. The regular SWE intern, not Meraki.
Well, as you have read from the title. This is by far the worst OA I have ever taken and I bombed it.
It is LeetCode style questions in which you just have to implement a function and pass all testcases.
People on Reddit tend to say it is hard to not pass Cisco OA because it is just 3 LeetCode Easies.
We are given 90 minutes for 3 questions, and I am not ashamed to admit that I didn't even solve 1.
(Feel free to skip the section below and scroll to the bottom if you are just interested in the question)
My first mistake is using C++
OK, here is the problem with Cisco OA platform. They have their own (stupid) platform and there is no debug output available for you to use. You can use cout or cerr to print to console and it won't show you anything. Great, that's fine, I don't need it anyways right? WRONG. I implemented a solution for Q1, which is just a question to verify if a string adheres to a format given about 10 rules. So I gave a solution and it just never worked (WA). I was there debugging for over an hour and I legit could not see what the issue with my code is. I got so frustrated that I grabbed my another device and typed my codes there to debug and it works!
So what the heck is going on?
Everything is initialized properly, how could the codes work on my machine but not on Cisco Server?
Upon further debugging I finally found out what the issue is.
The input is like this where the first number N is the number of string, followed by N lines of what I need to verify.
8
(90, 180)
(+90, -180)
(90., -90)
(90S, 129)
( 90, 38)
{83, -23)
(90.0, 38)
(038, 83)If the above test case looks like an absolute pain to verify if it follows a bunch of rules, yes, it is a pain.
And this is their parser.
// Warning: You are not supposed to modify these codes
int num_of_string
cin >> num_of_string
vector<string> all_the_string;
for (int i = 0; i < all_the_string.size(); ++i){
string temp;
cin >> temp;
all_the_string.push_back(temp);
}
vector<string> result = solve(all_the_string); // You have to implement solve()
for (int i = 0; i < result.size() - 1; ++i){
cout << result[i] << ' ';
}
cout << result[num_of_string - 1];
If you are a somewhat seasoned C++ user, you should immediately spot 2 huge issues with this.
.size() without casting it int first and then minus 1 from it is super dangerous because it won't work if the vector size is 0OK, I fixed these 2 issues. Is that all? WRONG.
The hidden answer comparison data is formatted differently than
for (int i = 0; i < result.size() - 1; ++i){
cout << result[i] << ' ';
}So I ended up having to fix that too.
When I finally figured out all of these, I already ran out of 90 minutes.
Why do some companies have such broken parsers that went unnoticed? Cisco is not even a small company. This is baffling to me.
Given a vector of strings. A string is considered valid when it is in the format of (X, Y).
X and Y is a whole number without decimal places.X and Y can't have leading zerosX >= -90X <= 90Y >= -180Y <= 180,( and X) and Y()X and Y can start with - or +Return a vector of string. "Valid" if the corresponding string is valid, otherwise it is "Invalid".
The input string can be any character of any size.
I think sscanf() should be useful for this problem. I generally do not like these kind of problems.