brain

tamnd's digital brain — notes, problems, research

41839 notes

LeetCode 3260 - Find the Largest Palindrome Divisible by K

The problem asks us to construct the largest possible palindrome with exactly n digits such that the resulting number is divisible by k. A palindrome is a number that reads the same forward and backward. For example, 595, 1221, and 8 are palindromes.

leetcodehardmathstringdynamic-programminggreedynumber-theory
LeetCode 3224 - Minimum Array Changes to Make Differences Equal

The problem gives us an integer array nums of even length n and an integer k. We are allowed to change any element in nums to any integer in the range [0, k].

leetcodemediumarrayhash-tableprefix-sum
LeetCode 3206 - Alternating Groups I

The problem gives us a circular array called colors, where each element represents the color of a tile: - 0 means red - 1 means blue Because the tiles form a circle, the first and last tiles are considered adjacent.

leetcodeeasyarraysliding-window
LeetCode 3188 - Find Top Scoring Students II

This problem asks us to identify students who satisfy a combination of academic requirements based on their major, completed courses, grades, and overall GPA. We are given three tables: - The students table stores each student's identity and declared major.

leetcodeharddatabase
LeetCode 3176 - Find the Maximum Length of a Good Subsequence I

We are given an integer array nums and a non-negative integer k. We need to find the maximum possible length of a subsequence such that the number of adjacent unequal pairs is at most k.

leetcodemediumarrayhash-tabledynamic-programming
LeetCode 3151 - Special Array I

The problem asks us to determine whether a given integer array is "special". An array is considered special if every pair of adjacent elements has different parity. Parity refers to whether a number is even or odd.

leetcodeeasyarray
LeetCode 3119 - Maximum Number of Potholes That Can Be Fixed

We are given a road represented as a string containing only two characters: - 'x' represents a pothole. - '.' represents a smooth section of road. We are also given a repair budget. A repair operation can only be applied to a contiguous group of potholes.

leetcodemediumstringgreedysorting
LeetCode 3135 - Equalize Strings by Adding or Removing Characters at Ends

The problem gives us two strings, initial and target. We want to transform initial into target using the minimum number of operations.

leetcodemediumstringbinary-searchdynamic-programmingsliding-windowhash-function
LeetCode 3108 - Minimum Cost Walk in Weighted Graph

This problem gives us an undirected weighted graph with n vertices and up to 10^5 edges. Each edge connects two vertices and has an integer weight. For every query [s, t], we must determine the minimum possible cost of any walk from node s to node t.

leetcodehardarraybit-manipulationunion-findgraph-theory
LeetCode 3074 - Apple Redistribution into Boxes

The problem asks us to redistribute a collection of apple packs into boxes while using the minimum number of boxes. Each pack apple[i] contains a certain number of apples, and each box capacity[j] can hold up to a certain number of apples.

leetcodeeasyarraygreedysorting
LeetCode 2976 - Minimum Cost to Convert String I

This problem asks us to transform one string into another while minimizing the total conversion cost. We are given two strings, source and target, both with the same length. Each position in source must eventually become the corresponding character in target.

leetcodemediumarraystringgraph-theoryshortest-path
LeetCode 2999 - Count the Number of Powerful Integers

The problem asks us to count all integers within a given range [start, finish] that satisfy two conditions. First, the integer must end with a specific string s, meaning s is a suffix of the number. Second, each digit in the integer cannot exceed a given limit.

leetcodehardmathstringdynamic-programming
LeetCode 2740 - Find the Value of the Partition

We are given an array nums containing positive integers. Our task is to divide all elements into two non-empty groups, nums1 and nums2. Every element must belong to exactly one of the two groups, and neither group may be empty.

leetcodemediumarraysorting
LeetCode 2527 - Find Xor-Beauty of Array

The problem defines a special value called the "effective value" for every possible triplet of indices (i, j, k) in the array: where: - | is the bitwise OR operator - & is the bitwise AND operator The xor-beauty of the array is the XOR of the effective values for all possible…

leetcodemediumarraymathbit-manipulation
LeetCode 2387 - Median of a Row Wise Sorted Matrix

We are given an m × n matrix grid where every row is already sorted in non-decreasing order. The total number of elements in the matrix is guaranteed to be odd because both m and n are odd. The task is to find the median of all values contained in the matrix.

leetcodemediumarraybinary-searchmatrix
LeetCode 1992 - Find All Groups of Farmland

In this problem, we are given a binary matrix called land. Each cell contains either: - 0, representing forest land - 1, representing farmland The farmland cells are organized into rectangular groups. Every group is guaranteed to form a perfect rectangle made entirely of 1s.

leetcodemediumarraydepth-first-searchbreadth-first-searchmatrix
LeetCode 1960 - Maximum Product of the Length of Two Palindromic Substrings

The problem asks us to find two non-overlapping odd-length palindromic substrings whose length product is as large as possible. We are given a string s of length up to 10^5.

leetcodehardtwo-pointersstringrolling-hashhash-function
LeetCode 1963 - Minimum Number of Swaps to Make the String Balanced

The problem asks us to transform a given string of brackets into a balanced string with the minimum number of swaps. The input string s consists of n characters, where n is even, and there are exactly n / 2 opening brackets '[' and n / 2 closing brackets ']'.

leetcodemediumtwo-pointersstringstackgreedy
LeetCode 1913 - Maximum Product Difference Between Two Pairs

This problem asks us to find the maximum product difference between two pairs of numbers from a given array. Specifically, given an array nums, we need to select four distinct indices w, x, y, z to form two pairs (nums[w], nums[x]) and (nums[y], nums[z]).

leetcodeeasyarraysorting
LeetCode 1782 - Count Pairs Of Nodes

We are given an undirected graph with n nodes and a list of edges. Multiple edges between the same pair of nodes are allowed. For any pair of nodes (a, b), define incident(a, b) as the number of edges connected to either node a or node b.

leetcodehardarrayhash-tabletwo-pointersbinary-searchgraph-theorysortingcounting
LeetCode 1880 - Check if Word Equals Summation of Two Words

The problem asks us to determine if the sum of the numerical values of two words equals the numerical value of a third word. Each word consists of lowercase letters from 'a' to 'j'.

leetcodeeasystring
LeetCode 1867 - Orders With Maximum Quantity Above Average

The problem asks us to identify "imbalanced orders" from an OrdersDetails table. Each row represents a product within an order, containing the orderid, productid, and quantity ordered. An order can have multiple products, meaning multiple rows can share the same orderid.

leetcodemediumdatabase
LeetCode 1851 - Minimum Interval to Include Each Query

The problem gives us a collection of inclusive integer intervals and a list of query values. For every query, we must determine the size of the smallest interval that contains that query value.

leetcodehardarraybinary-searchsweep-linesortingheap-(priority-queue)
LeetCode 1844 - Replace All Digits with Characters

In this problem, we are given a string s where characters at even indices are always lowercase English letters, and characters at odd indices are always digits. The goal is to replace every digit with a new character computed from the character immediately before it.

leetcodeeasystring
Lesson 17: Environmental Policy

Engage with Chinese environmental policy discourse, mastering the vocabulary of climate, sustainability, and environmental governance.

hsk-5lessonb2
JLPT N1 — Grammar

Complete JLPT N1 grammar reference: ~200 patterns including classical Japanese influences, literary forms, highly formal conjunctions, advanced conditionals, and nuanced distinctions separating N1 from N2.

japanesejlptjlpt-n1grammarlanguage-learning
记忆力 (jìyìlì) — memory (ability)

HSK 5 | noun | the capacity or power to remember

hsk-5vocabularyb2
一方面…另一方面 (yī fāngmiàn… lìng yī fāngmiàn) — On one hand… on the other hand

HSK 4 | grammar pattern | presenting two contrasting or complementary aspects

hsk-4vocabularyb1
过敏 (guòmǐn) — allergy; to be allergic

HSK 4 | noun/verb | an immune reaction to a normally harmless substance

hsk-4vocabularyb1
适应 (shìyìng) — to adapt; to adjust to

HSK 5 | verb | to adapt oneself or something to new conditions or requirements

hsk-5vocabularyb2
CF 474F - Ant colony

We are given a line of ants, each with an integer strength. Mole wants to observe fights among ants in specified contiguous segments of the line. For a given segment from position l to r, every ant fights every other ant within that segment.

codeforcescompetitive-programmingdata-structuresmathnumber-theory
CF 454B - Little Pony and Sort by Shift

We are given a sequence of integers arranged in a line, and our goal is to sort them in non-decreasing order by repeatedly performing a single allowed operation: moving the last element of the sequence to the front.

codeforcescompetitive-programmingimplementation
CF 457D - Bingo!

We have an $n times n$ bingo board. Every cell contains a distinct number chosen from $1$ to $m$, and every valid board is equally likely. After the board is generated, exactly $k$ distinct numbers are called. Every set of $k$ numbers is equally likely.

codeforcescompetitive-programmingcombinatoricsmathprobabilities
传媒 (chuánméi) — media; mass media

HSK 5 | noun | media; mass media; communications industry

hsk-5vocabularyb2
对不起 (duìbuqǐ) — sorry; I apologize

HSK 1 | greeting phrase | expresses sincere apology for a mistake or inconvenience

hsk-1vocabularya1
吧 (ba) — suggestion and assumption particle

HSK 2 | particle | softens suggestions, assumptions, and tag questions

hsk-2vocabularya1
客户 (kèhù) — Client

HSK 4 | noun | client, customer

hsk-4vocabularyb1
万 — JLPT N5 Kanji

万 (man/ban/yorozu): ten thousand. JLPT N5 kanji.

japanesekanjin5jlpt
慢性病 (mànxìngbìng) — chronic disease; chronic illness

HSK 5 | noun | chronic disease; long-term illness that persists over time

hsk-5vocabularyb2
十 (shí) — ten

HSK 1 | number | the digit ten; the base unit of the decimal system in Chinese

hsk-1vocabularya1
Lesson 8: Legal Language

The grammar and vocabulary of Chinese legal discourse — statutory language, contract clauses, and the register of rights, obligations, and liability

hsk-6lessonc1
鼓舞 (gǔwǔ) — to inspire; to encourage; inspiring

HSK 5 | verb/noun | to uplift and motivate someone through an energising or moving influence

hsk-5vocabularyb2
Travel Vocabulary

Japanese travel vocabulary: transportation, accommodation, directions, airports, stations, and essential travel phrases.

japanesevocabularytraveljlpt-n4language-learning
独特 (dútè) — Unique, distinctive, original

HSK 5 | adjective | having a quality or style that belongs only to itself; unique

hsk-5vocabularyb2
有效 (yǒuxiào) — effective, valid

HSK 5 | adjective | producing the desired result; legally or formally valid

hsk-5vocabularyb2
专业 (zhuānyè) — major; professional; specialized

HSK 5 | noun/adjective | academic major; professional field; specialized

hsk-5vocabularyb2
入 — Kanji Reference

入 (enter): 2 strokes, JLPT N5. On: ニュウ. Kun: い-る、い-れる、はい-る.

japanesekanjin5writing
智能化 (zhìnénghuà) — intelligentization, to make smart

HSK 5 | noun / verb | the process of embedding AI or smart technology into systems and products

hsk-5vocabularyb2
Lesson 8: Pronouns — Nominative

Sindarin subject pronouns: independent forms for emphasis and suffix forms attached to verbs; all 6 persons with attested examples.

sindaringrammarpronounsbeginner
送る (おくる) — Japanese Vocabulary

送る (おくる / okuru): to send. N4 level Japanese vocabulary.

japanesevocabularyn4verb-u
CF 479B - Towers

We are given several stacks of unit cubes, each stack having an initial height. In a single move, we can take exactly one cube from the top of one stack and place it on top of another stack.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgreedyimplementationsortings
况且 (kuàngqiě) — moreover; besides; furthermore

HSK 4 | conjunction | adding a reinforcing reason or point

hsk-4vocabularyb1
Body and Health Vocabulary

Japanese body parts, health, illness, injury, and medical vocabulary for everyday use and JLPT N5–N3.

japanesevocabularybodyhealthjlpt-n4language-learning
Lesson 1: The Accusative Case In Depth

Master all uses of the -n ending: direct object, direction, time measure, and flexible word order.

esperantob1lesson
四 — JLPT N5 Kanji

四 (shi/yot-tsu): four. JLPT N5 kanji.

japanesekanjin5jlpt
流体动力学 (liútǐ dònglìxué) — fluid dynamics

HSK 8 | noun | fluid dynamics; the study of forces and motion in liquids and gases

hsk-8vocabularyc2
相比之下 (xiāng bǐ zhī xià) — by comparison, in contrast

HSK 4 | phrase | used to introduce a comparison

hsk-4vocabularyb1
选择 (xuǎnzé) — to choose; to select; choice

HSK 4 | verb/noun | the act of choosing or a choice made

hsk-4vocabularyb1
满意 (mǎnyì) — satisfied, content

HSK 2 | adjective | feeling that expectations have been met

hsk-2vocabularya1
动词+不/得+结果 — verb + potential complement

HSK 3 | grammar pattern | expresses whether an action can or cannot achieve its result

hsk-3vocabularya2grammar
JLPT N4 — Kanji

All 181 new N4 kanji with stroke counts, on-yomi, kun-yomi, meanings, and example words. Cumulative total with N5: 284 kanji.

japanesejlptjlpt-n4kanjilanguage-learning
后悔 (hòuhuǐ) — to regret; to feel sorry

HSK 3 | verb | to feel regret about a past action

hsk-3vocabularya2
关心 (guānxīn) — to care about

HSK 3 | verb | to care about, show concern for someone or something

hsk-3vocabularya2
用 (yòng) — to use

HSK 1 | verb, preposition | to use, to employ, with (using)

hsk-1vocabularya1
〜てからというもの — JLPT N2 Grammar

Learn 〜てからというもの to express a fundamental, sustained change that began at a specific turning point.

japanesegrammarn2jlpt
垄断 (lǒngduàn) — monopoly; to monopolize

HSK 5 | noun / verb | monopoly; to monopolize, to dominate exclusively

hsk-5vocabularyb2
Lesson 11: Soft Mutation (Lenition)

Complete guide to Sindarin soft mutation: all 11 initial consonant changes, every trigger category, and 30+ worked examples from Tolkien's texts.

sindaringrammarmutationssoft-mutationintermediate
想象 (xiǎngxiàng) — to imagine; imagination

HSK 4 | verb / noun | to imagine; imagination

hsk-4vocabularyb1
虚伪 (xūwěi) — hypocritical / false

HSK 4 | adjective | hypocritical; false; insincere

hsk-4vocabularyb1
CF 466C - Number of Ways

We are given a sequence of integers arranged in a line, and we want to split it into three contiguous segments. The cut points must produce three non-empty parts, and each part must have exactly the same sum.

codeforcescompetitive-programmingbinary-searchbrute-forcedata-structuresdptwo-pointers
明白 (míngbai) — to understand, clear

HSK 2 | verb / adjective | to suddenly understand a situation; contrast with 懂 for skill-based comprehension

hsk-2vocabularya1
社会 (shèhuì) — society

HSK 5 | noun | the aggregate of people living together in a structured community

hsk-5vocabularyb2
食材 (shícái) — ingredient, foodstuff

HSK 4 | noun | a raw material or component used in cooking

hsk-4vocabularyb1
Lesson 24: Oral Proficiency (HSKK Advanced)

HSKK advanced patterns, spoken coherence strategies, and the pragmatics of formal spoken Chinese at C1 level

hsk-6lessonc1
遏制 (èzhì) — to restrain, to curb

HSK 6 | verb | to hold back or suppress the spread or growth of something

hsk-6vocabularyc1
书 (shū) — book

HSK 1 | noun | book

hsk-1vocabularya1
Lesson 15: Passive Voice — Present, Imperfect, and Future

Passive voice endings for all conjugations in present, imperfect, and future indicative; agent vs. means constructions; and a preview of the perfect passive.

latinnovicelesson
〜べく — JLPT N1 Grammar

N1 grammar pattern 〜べく: a formal literary purposive expressing 'in order to ~, for the purpose of ~' — the written formal equivalent of ために.

japanesegrammarn1jlpt
Lesson 4: Political & Social Discourse

Navigating the formal connective chains and specialized vocabulary of Chinese political and social commentary at C1 level

hsk-6lessonc1
政治 (zhèngzhì) — politics, political

HSK 5 | noun / adjective | the activity of governance; relating to political affairs

hsk-5vocabularyb2
表述 (biǎoshù) — to describe, to formulate

HSK 6 | verb | to express or articulate ideas clearly and systematically

hsk-6vocabularyc1
Lesson 2: Greetings & Basic Phrases

Essential Sindarin greetings and phrases directly from Tolkien's texts: Mae govannen, Hannon le, Navaer, Le abdollen, and more.

sindaringreetingsphrasesbeginner
模型 (móxíng) — model

HSK 5 | noun | a physical, mathematical, or conceptual representation of a system or object

hsk-5vocabularyb2
字 (zì) — character; word; handwriting

HSK 3 | noun | a written character, word, or one's handwriting

hsk-3vocabularya2
再 (zài) — again (future), then, more

HSK 2 | adverb | again (future repetition), then, one more time

hsk-2vocabularya1
用户 (yònghù) — user

HSK 5 | noun | a person who uses a product, service, or system

hsk-5vocabularyb2
CF 461D - Appleman and Complicated Task

We are given an $n times n$ grid that is mostly empty, except for a small number of cells that are already fixed as either x or o. Every other cell must be filled with one of these two characters.

codeforcescompetitive-programmingdsumath
Lesson 2: The Participle System

Master all six Esperanto participles — active and passive, present, past, and future — and their use as adjectives, adverbs, and in compound tenses.

esperantob1lesson
女人 (nǚrén) — woman

HSK 1 | noun | woman, female adult

hsk-1vocabularya1
Lesson 8: Political Discourse Analysis

Analyzing 政治语体: the vocabulary, rhetoric, and pragmatics of Chinese political communication.

hsk-7lessonc2
〜てたまらない — JLPT N2 Grammar

Learn how to use 〜てたまらない (te tamaranai) to express unbearable or overwhelming feelings, sensations, or desires — 'can't stand ~; unbearably ~.' Includes structure, nuance, examples, and comparisons.

japanesegrammarn2jlpt
评论 (pínglùn) — to comment on; commentary; review

HSK 4 | verb / noun | offering analysis or opinion on something

hsk-4vocabularyb1
数字经济 (shùzì jīngjì) — digital economy

HSK 5 | noun | economic activity driven by digital technologies and data

hsk-5vocabularyb2
手机 (shǒujī) — smartphone

HSK 1 | noun | mobile phone, smartphone

hsk-1vocabularya1
JLPT N4 — Structured Lessons

10 structured lessons for JLPT N4: from reviewing N5 basics to complex grammar, passive/causative, conditionals, and practical reading/writing. Each lesson includes dialogues and exercises.

japanesejlptjlpt-n4lessonslanguage-learning
幸福 (xìngfú) — happiness; happy; blessed

HSK 3 | noun/adjective | a deep sense of contentment and well-being

hsk-3vocabularya2
地铁 (dìtiě) — subway, metro

HSK 1 | noun | subway, underground railway

hsk-1vocabularya1
康复 (kāngfù) — to recover; rehabilitation

HSK 5 | verb/noun | to return to health after illness or injury; the process of recovery

hsk-5vocabularyb2
Lesson 14: Prefixes

Sindarin word-building with prefixes: directional, negative, intensifying, and stative prefixes with 40+ examples from attested names.

sindarinvocabularyprefixesintermediate
失望 (shīwàng) — disappointed; to lose hope

HSK 3 | adjective/verb | to feel let down; to be disappointed

hsk-3vocabularya2