Skip to content

NVIDIA Coding Questions - DSA Problems & Solutions

Practice NVIDIA placement paper coding questions with detailed solutions. Access NVIDIA OA coding problems in C++, Python.

This page contains NVIDIA coding questions from NVIDIA OA placement papers with detailed solutions.

NVIDIA OA Coding Section:

  • Problems: 2-3 coding problems
  • Time: 90 minutes
  • Languages: C++, Python
Q1: Given a large array, compute the sum using parallel processing concepts.

Solution (C++):

#include <vector>
#include <thread>
#include <numeric>
int parallelSum(vector<int>& arr, int numThreads) {
int n = arr.size();
int chunkSize = n / numThreads;
vector<thread> threads;
vector<int> partialSums(numThreads, 0);
for (int i = 0; i < numThreads; i++) {
int start = i * chunkSize;
int end = (i == numThreads - 1) ? n : (i + 1) * chunkSize;
threads.emplace_back([&, start, end, i]() {
partialSums[i] = accumulate(arr.begin() + start,
arr.begin() + end, 0);
});
}
for (auto& t : threads) t.join();
return accumulate(partialSums.begin(), partialSums.end(), 0);
}

Time Complexity: O(n/p) where p is number of threads


Practice NVIDIA coding questions regularly!