SAP Labs, Recently Asked Online Assessments in 2026 | Optimize Max Distance Algorithm

Question · Posted Apr 2026

Task 1: Optimize Max Distance Algorithm Problem Statement: Write an efficient algorithm for the following assumptions: N is an integer within the range [1..100,000]; each element of array A is an integer within the range [1..N]. The original code is: #include <algorithm> #include <vector> using namespace std; int solution(vector<int> &A) {     int N = A.size();     int result = 0;     for (int i = 0; i < N; i++)         for (int ...

The full answer & interview discussion are available to premium members.

Log in Create a free account