Skip to content

Commit 41ac24d

Browse files
authored
Update design-a-text-editor.cpp
1 parent 832fe89 commit 41ac24d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

C++/design-a-text-editor.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,23 @@ class TextEditor {
2929
for (int _ = 0; _ < cnt; ++_) {
3030
right_.push_back(left_.back()); left_.pop_back();
3131
}
32-
return last_10();
32+
return last_characters();
3333
}
3434

3535
string cursorRight(int k) {
3636
const int cnt = min(k, static_cast<int>(size(right_)));
3737
for (int _ = 0; _ < cnt; ++_) {
3838
left_.push_back(right_.back()); right_.pop_back();
3939
}
40-
return last_10();
40+
return last_characters();
4141
}
4242

4343
private:
44-
string last_10() {
45-
return left_.substr(max(static_cast<int>(size(left_)) - 10, 0), 10);
44+
string last_characters() {
45+
return left_.substr(max(static_cast<int>(size(left_)) - LAST_COUNT, 0), LAST_COUNT);
4646
}
4747

48+
static const int LAST_COUNT = 10;
4849
string left_;
4950
string right_;
5051
};

0 commit comments

Comments
 (0)