leetcode

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

commit02f0bc8b11a97cb8429c00c7937c855fdb3419f8
parentc270c9f8ec441e3173ef5b39276afcb9ba7edf2e
authorDimitrije Dobrota <mail@dimitrijedobrota.com>
dateThu, 2 Feb 2023 14:39:20 +0100

Daily Problem

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

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


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

@@ -0,0 +1,10 @@

class Solution {
public:
bool isAlienSorted(vector<string> &words, string order) {
vector<char> um(26);
for (int i = 0; i < order.size(); i++) um[order[i] - 'a'] = 'a' + i;
for (string &word : words)
for_each(word.begin(), word.end(), [&um](char &c) { c = um[c - 'a']; });
return is_sorted(words.begin(), words.end());
}
};

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

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

| 0944 | Easy | [Delete Columns to Make Sorted](Problems/0944.cpp) |
| 0947 | Medium | [Most Stones Removed with Same Row or Column](Problems/0947.cpp) |
| 0950 | Medium | [Reveal Cards In Increasing Order](Problems/0950.cpp) |
| 0953 | Easy | [Verifying an Alien Dictionary](Problems/0953.cpp) |
| 0959 | Medium | [Regions Cut By Slashes](Problems/0959.cpp) |
| 0965 | Easy | [Univalued Binary Tree](Problems/0965.cpp) |
| 0974 | Medium | [Subarray Sums Divisible by K](Problems/0974.cpp) |