Stand tall with weight on one leg. Keep your legs straight, but knees soft, with a slight bend in them. Hinging only at the hips (keeping chest and back straight), swing the elevated leg back behind you until you feel a good stretch in the hamstrings of your standing leg. Aim to bring your elevated leg up high enough to draw a straight line across your back to your leg. Once you reach that deep stretch, return the outstretched leg to standing, relax and and change sides, repeating on the opposite leg.
If you have trouble balancing, use an anchor for your hands. This also works if you wish to emphasize the stretch instead of just your balance.