leetcode

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

commit5d15ab57b80ee97c427058cd8841847ea943dec1
parent2e052050a026f65c089fd2c5f7207b4eb0b5bde0
authorDimitrije Dobrota <mail@dimitrijedobrota.com>
dateMon, 18 Mar 2024 19:04:44 +0000

1 Random Problem

Diffstat:
AProblems/1855.cpp|++++++++++++++++
MREADME.md|+

2 files changed, 17 insertions(+), 0 deletions(-)


diff --git a/Problems/1855.cpp b/Problems/1855.cpp

@@ -0,0 +1,16 @@

class Solution {
public:
int maxDistance(const vector<int> &nums1, const vector<int> &nums2) const {
const int n = size(nums1), m = size(nums2);
int res = 0, i = 0, j = 0;
while (i < n && j < m) {
if (nums1[i] > nums2[j])
i++;
else
res = max(res, j++ - i);
}
return res;
}
};

diff --git a/README.md b/README.md

@@ -932,6 +932,7 @@ for solving problems.

| 1845 | Medium | [Seat Reservation Manager](Problems/1845.cpp) |
| 1846 | Medium | [Maximum Element After Decreasing and Rearranging](Problems/1846.cpp) |
| 1850 | Medium | [Minimum Adjacent Swaps to Reach the Kth Smallest Number](Problems/1850.cpp) |
| 1855 | Medium | [Maximum Distance Between a Pair of Values](Problems/1855.cpp) |
| 1857 | Hard | [Largest Color Value in a Directed Graph](Problems/1857.cpp) |
| 1860 | Medium | [Incremental Memory Leak](Problems/1860.cpp) |
| 1861 | Medium | [Rotating the Box](Problems/1861.cpp) |