Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions 1492/solution.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class Solution {
public:
int kthFactor(int n, int k) {
int i,j=0;
for(i=1;i<=n;i++){

if(n%i==0)
{
j++;
if(j==k)
return i;
}

}
return -1;
}
};
16 changes: 16 additions & 0 deletions 239-Sliding-window-maximum/239-Sliding-Windowm-maximum.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class Solution {
public:
vector<int> maxSlidingWindow(vector<int>& nums, int k) {
multiset<int>c;
vector<int>ans;
for(int i=0;i<nums.size();i++)
{
if(i>=k)
c.erase(c.find(nums[i-k]));
c.insert(nums[i]);
if(i>=k-1)
ans.push_back(*c.rbegin());
}
return ans;
}
};
24 changes: 24 additions & 0 deletions 384-Shuffle-an Array/Shuffle-an-Arraay.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
class Solution {
public:
vector<int>a,t;
Solution(vector<int>& nums) {
a=nums;
t=nums;
}

vector<int> reset() {
return t;
}

vector<int> shuffle() {
prev_permutation(a.begin(),a.end());
return a;
}
};

/**
* Your Solution object will be instantiated and called as such:
* Solution* obj = new Solution(nums);
* vector<int> param_1 = obj->reset();
* vector<int> param_2 = obj->shuffle();
*/
1 change: 1 addition & 0 deletions Data-Structures-and-Algorithms
Submodule Data-Structures-and-Algorithms added at f1c3ff