leetcode

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

commit e6ae45a905a90b80fffa4e2f833165f0060ff49a
parent 05833ad731709a38054c13ce73e2bb0ba1ebdb6a
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Sat,  3 Aug 2024 19:51:04 +0200

Daily Problem

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

diff --git a/Problems/1460.cpp b/Problems/1460.cpp @@ -0,0 +1,14 @@ +class Solution { + public: + bool canBeEqual(const vector<int> &target, const vector<int> &arr) const { + static int um[1001]; + + memset(um, 0x00, sizeof(um)); + for (const int n : target) + um[n]++; + for (const int n : arr) + if (!um[n]--) return false; + + return true; + } +}; diff --git a/README.md b/README.md @@ -833,6 +833,7 @@ for solving problems. | 1456 | Medium | [Maximum Number of Vowels in a Substring of Given Length](Problems/1456.cpp) | | 1457 | Medium | [Pseudo-Palindromic Paths in a Binary Tree](Problems/1457.cpp) | | 1458 | Hard | [Max Dot Product of Two Subsequences](Problems/1458.cpp) | +| 1460 | Easy | [Make Two Arrays Equal by Reversing Subarrays](Problems/1460.cpp) | | 1461 | Medium | [Check If a String Contains All Binary Codes of Size K](Problems/1461.cpp) | | 1462 | Medium | [Course Schedule IV](Problems/1462.cpp) | | 1463 | Hard | [Cherry Pickup II](Problems/1463.cpp) |