The enhancement of the vastus medialis is of considerable importance for patellar stabilization and of the knee joint in general. As you probably know, the vastus medialis is one of the four heads that form the quadriceps muscle and its main function is to extend the leg.
In the case of patellar femoral pathologies it is advisable to work limiting the flexion angle as much as possible, just as the orthopedist advised you (in this way you avoid excessive compression of the patella on the femur and the possible onset of cartilage pathologies).
Furthermore, the greatest involvement of the vastus medialis in the movement occurs precisely in the last degrees of extension, this involvement further increases if the foot is extra-rotated (toe facing outwards) and if a co-contraction of the adductor muscles is performed at the same time. (for example by squeezing a ball or pillow between the thighs).
Not all leg extensions are equipped to limit the degrees of flexion-extension. Technogym, for example, builds adjustable leg extensions.
If your gym is not equipped with machinery of this kind, either you go to a specialized center or you can use elastic bands or anklets and perform the exercise while sitting (foot forward so that the knee is semi-flexed (45 °) , toe out, extend the leg just like you do in the leg extension, repeat 20-30 times and switch limbs).
As for hamstring stretching, you can perform the following exercises in a slow and controlled manner.
Yours sincerely.