Given a sorted integer array nums (length n) and an integer target t, return the index of the first element in nums that is greater than or equal to t. If no such element exists, return -1. Provide both iterative and recursive implementations, handle duplicate values correctly, and analyze time and space complexity. Explain how you would adapt your solution to find the last element less than or equal to t.