The focus here is to stretch through the hamstring - if you feel a stretch through the back of the knee bend the leg a little.
Easier = foot on the floor
Difficult = foot on the table
Keep the lower back as flat or arched as possible and squeeze the quad of the working leg to protect the knee when in the deepest stretch.
For the lift the priority is to lock out the lifted leg. Once this is ok also make sure the base leg is straight and you are not leaning back. Don’t worry about using a wall or something to help keep your balance.