leetcode

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

commit5bf89e793b9e662d2e6595c03219873424fd5fb4
parentc5d6dff82d4fd9c7291be0d802bad4b7ebcc8074
authorDimitrije Dobrota <mail@dimitrijedobrota.com>
dateMon, 2 Dec 2024 14:31:11 +0100

Daily Problem

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

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


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

@@ -0,0 +1,15 @@

class Solution {
public:
int isPrefixOfWord(const string &sentence, const string &searchWord) const {
stringstream ss(sentence);
int idx = 1;
string s;
while (ss >> s) {
if (s.starts_with(searchWord)) return idx;
idx++;
}
return -1;
}
};

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

@@ -925,6 +925,7 @@ reference and a base for solving problems.

| 1448 | Medium | [Count Good Nodes in Binary Tree](Problems/1448.cpp) |
| 1451 | Medium | [Rearrange Words in a Sentence](Problems/1451.cpp) |
| 1452 | Medium | [People Whose List of Favorite Companies Is Not a Subset of Another List](Problems/1452.cpp) |
| 1455 | Easy | [Check If a Word Occurs As a Prefix of Any Word in a Sentence](Problems/1455.cpp) |
| 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) |