leetcode

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

commit e868b4b50ad12e2a0a24900dc565f6bb2cbf4a90
parent b88b4777bef8a3a35c05812eaa3f4b05a68d8f9e
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Mon,  8 Jul 2024 14:49:30 +0200

1 Random Problem

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

diff --git a/Problems/3211.cpp b/Problems/3211.cpp @@ -0,0 +1,15 @@ +class Solution { + public: + vector<string> validStrings(int n) { + vector<string> res = {"0", "1"}; + + for (int i = 1; i < n; i++) { + for (int j = size(res) - 1; j >= 0; j--) { + if (res[j].back() == '1') res.push_back(res[j] + '0'); + res[j] += '1'; + } + } + + return res; + } +}; diff --git a/README.md b/README.md @@ -1281,3 +1281,4 @@ for solving problems. | 3106 | Medium | [Lexicographically Smallest String After Operations With Constraint](Problems/3106.cpp) | | 3110 | Easy | [Score of a String](Problems/3110.cpp) | | 3111 | Medium | [Minimum Rectangles to Cover Points](Problems/3111.cpp) | +| 3211 | Medium | [Generate Binary Strings Without Adjacent Zeros](Problems/3211.cpp) |