DEV Community

Andrew
Andrew

Posted on

"Spark" - 1 Week (22.06.2025)

Week 1 – Learning Log (22.06.2025)

🗓 Thursday

How's the first week going? Honestly, not bad at all.

  • I came up with a lot of new project ideas (not the focus this week though).
  • Created mnemonics for nearly all 84 vocabulary phrases, and I’m close to finishing.
  • I’ll soon start translation tests (Chinese <-> English) to measure real retention.
  • Will write down reasons why remembering them matters.

This week brought another intense wave of introspection and existential thoughts—but I made it through. Oddly enough, The Social Network movie helps me regain focus and motivation.

Algorithms I'm Starting With

I’ve selected 4 beginner-level problems to master:

  • ✅ Two Sum
  • ✅ Valid Parentheses
  • ✅ Best Time to Buy and Sell Stock
  • ✅ Valid Palindrome

I'll:

  • Study the most efficient solutions
  • Write pseudocode
  • Implement them in C++

My approach prioritizes speed, clarity, and adaptability. Critics might say I’m copying solutions. Fair. But my aim is to absorb as many techniques as possible before building things completely solo.

I've also started learning 5 computer theory topics—right down to electrical components. Why? Because I want to understand how things work beneath the code. I’ve also added a C++ topic for brushing up on fundamentals.

And despite it being 2 AM... I feel energized. Let's go. Even if AI takes over coding, I’ll keep living my narrative.


🗓 Sunday

It's been a tough but meaningful week.
⏰ 9:35 PM – Still finishing up:

  • Chinese vocabulary
  • LeetCode solutions
  • A bit of C++ and CS theory

I can't say I’ve mastered the technical theory yet, but now, when I revisit these ideas in the future, I’ll recognize and understand them much faster.

Meanwhile, I’m juggling some business projects too.
I registered my new domain: unpackly.com — development starts next week.

Still need to:

  • Identify the target audience
  • Find communities where they hang out
  • Begin engaging authentically

🛠️ Weekly Resources + LeetCode Review

One of my ongoing project ideas is building a tool that summarizes all your study content in seconds—so here's a "manual version" of that for now.

My LeetCode ID: feelsgood121
I used the following materials to study and solve these 4 problems:


🧠 4 Algorithms


1. Two Sum (Easy)

🔗 Link

One-Pass Hash Table stands out as the most time-efficient option, especially useful for larger datasets.

class Solution {
👉 Here we create a class named Solution. In C++, classes are like containers that hold functions and variables. On LeetCode, code is usually written inside such a class.

public:
👉 This is an access specifier. It means everything that follows inside the class is publicly accessible  other parts of the program can use these functions.

vector<int> twoSum(vector<int>& nums, int target) {
👉 Here we declare the twoSum function, which:

Returns a vector<int> (a list of numbers like [1, 2])
Takes two arguments:
vector<int>& nums  a list of numbers (e.g., [2, 7, 11, 15])
int target  the number we want as the sum of two elements from nums

unordered_map<int, int> numMap;
👉 We create a hash map (a fast data structure) that:

Stores pairs: number  its index
unordered_map<int, int> means: key and value are both int
Example: if nums = [2, 7], numMap might become {2: 0, 7: 1}

for (int i = 0; i < nums.size(); i++) {
👉 This starts a loop over all numbers in nums:
i is the index (0, 1, 2)
nums.size() gives the total count

int complement = target - nums[i];
👉 We calculate the complement  the number needed to reach the target with the current number.
E.g., target = 9, nums[i] = 2  complement = 7

if (numMap.count(complement)) {
👉 We check if this complement already exists in numMap.
numMap.count(x) returns 1 if x is in the map, 0 if not

return {numMap[complement], i};
👉 If the complement is found, we return the pair of indices:
numMap[complement]  index of the number weve already seen
i  current numbers index

🧠 This means weve found the two numbers that sum to target.
}

numMap[nums[i]] = i;
👉 If no match found yet, add the current number to the map:
Key = nums[i], Value = i
}

return {};
}
};
👉 Close the loop, function, and class. If no pair was found, we return an empty list.
Enter fullscreen mode Exit fullscreen mode

💡 Example

nums = [2, 7, 11, 15];
target = 9;
i = 0 → nums[i] = 2 → complement = 7 → not in map → add 2:0  
i = 1 → nums[i] = 7 → complement = 2 → found → return {0, 1}
Enter fullscreen mode Exit fullscreen mode

2. Valid Parentheses (Easy)

🔗 Link

This code checks whether brackets in a string are correctly closed.

Examples:

  • "()" → valid
  • "(]" → invalid
  • "({[]})" → valid

🔹 Main Code

class Solution {
👉 Creates the class Solution.

public:
👉 Makes everything below publicly accessible.

bool isValid(string s) {
👉 This is the function isValid:
Takes a string s (e.g., "(())")
Returns true if the parentheses are valid, else false

string stack;
👉 We use this string as a stack:
A stack lets you:
Push to the end
Pop from the end
Access the last added element

for (char c : s) {
👉 Loop through each character in s

if (c == '(' || c == '{' || c == '[') {
    stack.push_back(c);
}
👉 If its an opening bracket, we add it to the stack

else if (stack.empty() || !match(stack.back(), c)) {
    return false;
}
👉 If its a closing bracket:
Check if the stack is empty (then its invalid)
Or check if the bracket matches the last open one (match function)

else {
    stack.pop_back();
}
👉 If brackets match  remove the last open one
}

return stack.empty();
👉 If the stack is empty at the end  valid; otherwise  invalid
}

bool match(char left, char right) {
    return (left == '(' && right == ')') ||
           (left == '[' && right == ']') ||
           (left == '{' && right == '}');
}
👉 Checks if left and right form a valid pair.
};
Enter fullscreen mode Exit fullscreen mode

🔹 Example

string s = "({[]})";
( → push  
{ → push  
[ → push  
] → matches [ → pop  
} → matches { → pop  
) → matches ( → pop ✅  
→ Valid → returns true
Enter fullscreen mode Exit fullscreen mode

3. Best Time to Buy and Sell Stock (Easy)

🔗 Link

🔹 Purpose

This code solves the problem:

📈 Find the maximum profit from buying and selling a stock once.
(You can buy once and sell once — sell must be after buy)

Example:
If prices = [7, 1, 5, 3, 6, 4] → max profit = 6 - 1 = 5

🔹 Line-by-Line

#include <vector>
#include <algorithm>
👉 Includes libraries for vectors and functions like min/max

class Solution {
public:
    int maxProfit(vector<int>& prices) {
👉 The function receives a list of stock prices and returns max profit.

int max_profit = 0;
int min_price = prices[0];
👉 Start with 0 profit, and first price as the initial minimum

for (int price : prices) {
    max_profit = max(max_profit, price - min_price);
    min_price = min(min_price, price);
}
👉 For each price:
Calculate potential profit  update max_profit if it's better
Update min_price if todays price is lower

return max_profit;
👉 Return the best profit found
}
};
Enter fullscreen mode Exit fullscreen mode

🔹 Example

prices = [7, 1, 5, 3, 6, 4]
→ max profit = 5 ✅
Enter fullscreen mode Exit fullscreen mode

4. Valid Palindrome (Easy)

🔗 Link

Checks if a string is a palindrome, ignoring spaces, punctuation, and case.

🔹 What’s a palindrome?

A string that reads the same forward and backward.
"A man, a plan, a canal: Panama"
"race a car"

🔹 Line-by-Line

class Solution {
public:
    bool isPalindrome(string s) {
👉 Takes a string s and returns true if its a valid palindrome

int left = 0, right = s.size() - 1;
👉 Two pointers: left from start, right from end

while (left < right) {
👉 Loop until the pointers meet

if (!isalnum(s[left])) { ++left; }
else if (!isalnum(s[right])) { --right; }
👉 Skip non-alphanumeric characters

else if (tolower(s[left]) != tolower(s[right])) {
    return false;
}
👉 Compare characters (case-insensitive). If not equal  return false

else {
    ++left;
    --right;
}
👉 If they match  move inward
}

return true;
👉 If all characters matched  its a palindrome
}
};
Enter fullscreen mode Exit fullscreen mode

🔹 Example

"A man, a plan, a canal: Panama"
→ Cleaned: "amanaplanacanalpanama"
→ All characters match → returns true ✅
Enter fullscreen mode Exit fullscreen mode

🧠 Computer Science Topics I'm Studying

Focusing on low-level basics to truly understand how computers work:

  • Capacitor
  • Diode
  • Transistor
  • LED
  • Phototransistor

Maybe I’m going too deep. But who knows—maybe I’ll be an engineer one day. In any case, I’m enjoying it.


💻 C++ Focus This Week

I’m revisiting data types — still not 100% confident when solving real problems. But it’s getting better.


🈴 Weekly Chinese Vocabulary – 84 Words/Phrases
Here are most of the 84 words/phrases I’ve memorized this week:

Nǐ yǒu jǐ gè háizi?

Nǐ yǒu shénme àihào?

Nǐ qùguo Měiguó ma?

Nǐ de shǒujī hàomǎ shì duōshao?

Nǐ de yóuxiāng dìzhǐ shì shènme?

Xiànzài yǒu kòng ma?

Zuìjìn gōnzuò máng ma?

Nǐ měitiān jǐ diǎn shàngbāng?

Nǐ měitiān jǐ diǎn xiàbān?

Nǐ yǐqián zuòguo shénme gōngzuò?

Duì, bàituō le

Méi wèntí

Zhīdào le

Kěyǐ

Dāngrán kěyǐ

Yuánlái rúcǐ

Wǒ yě zhème rènwéi

Zhēn búcuò

Búyòng le

Wǒ bù míngbai

Wǒ bú zhème rènwéi

Bùxíng

Kěyǐ ma?

Nǐ néng bāng wǒ gè máng ma?

Bǎ mén guānshàng hǎo ma?

lái

Fēijī

shǎo

diěn

jiào

xiào

zài

cháng

ràng

xiūxi

zhāng

dào

yǐjīng

jué de

chàng gē

děng

hēi



zhe

wài

zhǔnbèi

mǎshàng

zuì



chū

yīn

hóng

shēng bìng

kuài lè

yuán

zhēn

duì

pǎobù

yánsè



jièshào

yùndòng

zhèngzài

lǚyóu

kěnéng

qīng

shíjiān

měi

jiàn

qiāng

yǎnjing

zìxíngchē



zhǎo

xīwàng

tiàowǔ

hái

cuò

shǒubiǎo

yīqǐ

gěi

gōngjīn

🎯 Final Thoughts

This week wasn't perfect, but it was real.
I didn’t try to do everything solo. I focused on learning deeply, making steady progress, and setting up systems that will pay off long-term.

Next up: Refining my learning tools, developing unpackly.com, and pushing further into CS theory and algorithms.

Even if the world changes, I'll keep building.

Top comments (0)