diff --git a/1492/solution.cpp b/1492/solution.cpp new file mode 100644 index 00000000..157f1287 --- /dev/null +++ b/1492/solution.cpp @@ -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; + } +}; \ No newline at end of file diff --git a/239-Sliding-Window-Maximum/sliding-window.cpp b/239-Sliding-Window-Maximum/sliding-window.cpp new file mode 100644 index 00000000..72316a8c --- /dev/null +++ b/239-Sliding-Window-Maximum/sliding-window.cpp @@ -0,0 +1,16 @@ +class Solution { +public: + vector maxSlidingWindow(vector& nums, int k) { + multisetc; + vectorans; + for(int i=0;i=k) + c.erase(c.find(nums[i-k])); + c.insert(nums[i]); + if(i>=k-1) + ans.push_back(*c.rbegin()); + } + return ans; + } +}; \ No newline at end of file diff --git a/384-Shuffle-an Array/Shuffle-an-Arraay.cpp b/384-Shuffle-an Array/Shuffle-an-Arraay.cpp new file mode 100644 index 00000000..560143fa --- /dev/null +++ b/384-Shuffle-an Array/Shuffle-an-Arraay.cpp @@ -0,0 +1,24 @@ +class Solution { +public: +vectora,t; + Solution(vector& nums) { + a=nums; + t=nums; + } + + vector reset() { + return t; + } + + vector 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 param_1 = obj->reset(); + * vector param_2 = obj->shuffle(); + */ \ No newline at end of file diff --git a/Data-Structures-and-Algorithms b/Data-Structures-and-Algorithms new file mode 160000 index 00000000..f1c3ff3e --- /dev/null +++ b/Data-Structures-and-Algorithms @@ -0,0 +1 @@ +Subproject commit f1c3ff3e60c0d38f1129dbdcdf578525491035c1