I sat for nearly ten minutes trying to decide whether to answer or not, because yes, this question is off-topic. On the other hand, how we physically write can influence what we write (keeping in mind people who flow better when hand-writing vs typing). What tipped the scales, though, was the "I was unable to finish my exam within the stipulated time despite knowing the answers" part. As a teacher, I feel the need to tell you what my teacher told me many years ago: letters have a 'right way' of being written, whether it's typeface or cursive, and the tools have a 'right way' of being held. If you know those two and practice them, you'll be able to write both swiftly and legibly.
So, before you think about dysgraphia (which I am in no way belittling), look at the way you hold your pencil/pen. Is your wrist rigid or flexible? Do you hold the pencil/pen with the thumb and the index finger, the middle finger maneuvring it? I have young students who learned to write three and four years ago and yet were not taught how to hold the pencil correctly. They have little dexterity and have trouble making precise shapes. Once they are taught how to hold the pencil correctly, they complain it is harder and painful. Why? because the muscles of the fingers were not exercised when there was little to write, and now they're faced with writing a lot of things when they don't have their hands exercised and fit for the task.
From the examples given, I can only say that the first image suggests that the hand is rigid and, when forced to write fast, proceeds in jumps and hiccups. Do notice I said suggests, based on similarly shaped letters as I see on my students and on how they write them.
When I went to University, my handwriting became terrible. I used tonnes of abbreviations, turned m and n into differently sized dashes, and invented symbols for common groups of letters. There were times I couldn't read my own notes. When I finished my course, I bought calligraphy lined paper and re-taught myself the correct way of writing the letters. First I traced the letters like first graders, then I started writing on the lined paper. For one year, I wrote every day on such paper. Sometimes it was a couple of lines, sometimes it was pages long. I started out slowly and imperfectly. Nowadays, I can write intelligibly at a fairly good speed, but I do notice that the less I write by hand, the more slowly I do so, and the less perfectly, too, as if my muscles have forgotten how to make the pen flow across the page. The old saying stands true: practice makes perfect.
First, find out if you are using the right pen-holding technique. If you have a poor grip and rigid muscles, you'll always tire yourself out. On the other hand, a proper grip will give you fluidity with relatively low effort (in due time).
Secondly, start your practice slowly and be persistent. You wouldn't start practicing for the marathon by running for two hours, would you? So start by writing slowly but fluidly and effortless (see the technique point above). When you get to that point, you can improve your speed little by little. In fact, you won't even have to do anything, as you'll find yourself writing more quickly of your own accord.