leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

commit 5537293c21d308449cf9c7ced6f6c8d04059270e
parent 09a5f47ff26ee85aa41e7b238cec78a8825575ec
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Wed, 22 Feb 2023 10:04:39 +0100

Algorithm II: Day 20

Diffstat:
AProblems/0384.cpp | 14++++++++++++++
MREADME.md | 1+
2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/Problems/0384.cpp b/Problems/0384.cpp @@ -0,0 +1,14 @@ +class Solution { + const vector<int> og; + vector<int> shuffing; + +public: + Solution(const vector<int> &nums) : og(nums), shuffing(nums) {} + + vector<int> reset() { return og; } + + vector<int> shuffle() { + random_shuffle(shuffing.begin(), shuffing.end()); + return shuffing; + } +}; diff --git a/README.md b/README.md @@ -213,6 +213,7 @@ for solving problems. | 0376 | Medium | [Wiggle Subsequence](Problems/0376.cpp) | | 0377 | Medium | [Combination Sum IV](Problems/0377.cpp) | | 0383 | Easy | [Ransom Note](Problems/0383.cpp) | +| 0384 | Medium | [Shuffle an Array](Problems/0384.cpp) | | 0387 | Easy | [First Unique Character in a String](Problems/0387.cpp) | | 0392 | Easy | [Is Subsequence](Problems/0392.cpp) | | 0394 | Medium | [Decode String](Problems/0394.cpp) |