Skip to content

Commit

Permalink
amazon
Browse files Browse the repository at this point in the history
  • Loading branch information
SuryankDixit committed Sep 11, 2021
1 parent 9ffaaaa commit 159069c
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
34 changes: 34 additions & 0 deletions Online Assessments/a1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include <bits/stdc++.h>
using namespace std;

// Function to find the nCr
void printNcR(int n, int r)
{
long long p = 1, k = 1;
if (n - r < r)
r = n - r;

if (r != 0)
{
while (r)
{
p *= n;
k *= r;
long long m = __gcd(p, k);
p /= m;
k /= m;
n--;
r--;
}
}
else
p = 1;
cout << p << endl;
}
int main()
{
int n = 50, r = 25;
printNcR(n, r);
return 0;
}
23280703509553
16 changes: 16 additions & 0 deletions Online Assessments/a2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
vector<int> result;
if (k == 0)
return result;
deque<int> w;
for (int i = 0, n = (int)nums.size(); i < n; i++)
{
while (!w.empty() && w.front() <= i - k)
w.pop_front();
while (!w.empty() && nums[w.back()] >= nums[i])
w.pop_back();
w.push_back(i);
if (i >= k - 1)
result.push_back(nums[w.front()]);
}
return result;
// 23280703509553 23280704696892 23280727722831

0 comments on commit 159069c

Please sign in to comment.