The correct, optimal and working solution for programming question search-insert-position on leetcode

#include <algorithm> class Solution { public: int searchInsert(int A[], int n, int target) { return (lower_bound(A,A+n,target) - A); } };