Life/PS
-
[LeetCode] 115. Distinct SubsequencesLife/PS 2026. 6. 15. 18:31
Please refer the description in comment
-
[LeetCode] 76. Minimum Window SubstringLife/PS 2026. 6. 7. 16:51
When require[ch] is positive or zero, letter ch in window exists enough to construct t. Else, -value is the required number of 'ch' to construct t.class Solution {public: string minWindow(string s, string t) { int ank, hok; int s_len = s.length(); int require[128] = { 0, }; int chk = 0; int res_len, res_idx; ank = 0; hok = 0; for(char ch: t) { ..
-
[LeetCode] 68. Text JustificationLife/PS 2026. 6. 4. 18:41
The code is much dirtier than I thought, but I can't think of a way to make it okay.class Solution {public: vector fullJustify(vector& words, int maxWidth) { int ch_cnt = 0; vector bag; vector res; for (string& word: words) { if (ch_cnt + !bag.empty() + word.length() > maxWidth) { string build; int num_ws = bag.size() - 1; ..
-
-
[LeetCode] 52. N-Queens IILife/PS 2026. 5. 29. 14:32
Refer [LeetCode] 51. N-Queens (https://kms-program.tistory.com/83) class Solution {public: int totalNQueens(int n) { int res = 0; vector col(n, false); vector diag1(2 * n - 1, false); vector diag2(2 * n - 1, false); vector queen(n, -1); int row = 0; int c = 0; for(;;) { bool placed = false; for(; c