Feeling like a failure because of a class
What you may be experiencing is the fact that insight into some areas of mathematics don't translate into insight into others. I had a lot of insight into Analysis (my field) and General Topology, but little in Abstract Algebra. I once took a course (grad level) in discrete math and did terribly, experiencing much of what you describe.
To be successful you need a fairly general understanding of much (but not all) of mathematics and a deep understanding of one or two narrow areas. If you can achieve that then you can be a success.
It hasn't been possible for an individual to understand (at any deep level) all of mathematics for about 100 years. There are likely only a few living computer science professionals that understand all of CS, if that is even possible at all anymore, given what has gone on in the last 10 years or so.
If you are early in your studies then work on breadth. If you are mid to late, then it is time for a deep dive.
I don't know the answer to this question, but I do have some idea for questions you might ask yourself.
I would guess that you are doing better in this class than you think you are, and overall you are probably stronger than this particular class indicates.
However, the job market is competitive, and I have every expectation that the current crisis will make the job market worse, permanently. How much worse I don't know. While you're not directly competing against your classmates, they are probably similar to some of the people you will be competing against.
I don't know where you are going to graduate school, so I don't know how good (on average) the other students are. If you are in a situation where only 5% of the students in your program get the kind of job you want, then you're probably in trouble; those 5% are likely to be at least above average at everything. If you are in a situation where 50% of the students in your program get the kind of job you want, then you could very well be part of that 50%.
Of course, it could very well be that, historically, 50% of the students in your program got the kind of job you want, but, because of the new job market, only 5% will going forward.