Leetcode 216 Combination Sum III
Leetcode Link
AnalysisIf we start with ( k = 3 ) and ( n = 9 ), we need to find all possible combinations of three distinct numbers from ( 1 ) to ( 9 ) that sum up to ( 9 ).
For example, the valid combinations are:
([1, 2, 6]) → sum = 9 ✅
([1, 3, 5]) → sum = 9 ✅
([2, 3, 4]) → sum = 9 ✅
This problem is similar to the subsets problem, where we explore different combinations by picking each number one at a time. The key difference is that we need to ensure the s ...
Leetcode 62 Unique Paths
Leetcode Link
To understand this problem, let’s begin by considering a simple example: a 2x2 maze. In this maze, you can only move right or down. To reach the bottom-right corner ([1, 1]), there are two possible paths:
Right → Down
Down → Right
Thus, we can conclude that for a 2x2 maze, there are 2 unique paths to reach the bottom-right corner.
Extending to Larger GridsLet’s consider a larger grid, such as a 3x7 maze. We can construct a matrix to represent the number of ways to reach each ...
Leetcode 735 Asteroid Collision
Leetcode Link
We can use a stack to solve this problem.
From the problem description, the planets move at the same speed, so we only need to consider their direction and size.Whether two planets will collide and the result of the collision can be divided into three cases:
asteroids = [5, 10] or asteroids = [-5, -10]
Both planets move in the same direction, so no collision occurs.
asteroids = [-5, 10]
The two planets move in different directions but will not collide.
asteroids = ...
Cloud Summit 2024 Participation Experience
OverviewAttending Cloud Summit for the first time allowed me to gain a deeper understanding of cloud technologies. I am quite happy to see that the industry has many new tools and technologies that simplify complex tasks, continuously pushing the capabilities of Taiwan’s software industry.
Of course, a speaker who discussed the double-edged nature of the Cloud, highlighting both its advantages and disadvantages. In this era of AI, technological iterations are happening rapidly, but the unchang ...
Two Ways to Set Up a Firewall in Linux
Firewall ConfigurationOn Ubuntu Linux, you can use ufw or iptables for firewall configuration. Here are the commands and some pitfalls I encountered along the way. 🤣
UFW
View firewall settings sudo ufw status
Add firewall rules # allow sshsudo ufw allow ssh# allow specific ip to specific portsudo ufw allow from 123.123.123.123 to any port 22/tcp
List firewall rules with numbers sudo ufw status numbered
Example root@localhost:~# sudo ufw status numberedStatus: active To ...
The maps below show an industrial area in the town of Norbiton, and planned future development of the site.
The two maps illustrate the variation in Norbiton town, showing the current industrial usage and the proposed future refurbishment of the area.
Overall, it is evident that there will be more accommodations and numerous facilities replacing the factories in the town.
Upon closer examination of the maps, many factories are situated along the routes, and there are still significant unused spaces. These factories will be replaced by a plethora of new apartments or flats to accommodate the rising p ...
It is important for people to take risks, both in their professional lives and their personal lives.
Do you think the advantages of taking risks outweigh the disadvantages?
Risk evaluation is a crucial aspect of decision-making, as uncertainty about the future often leads to feelings of unease and confusion. While some people argue taking risks could have adverse effects on one’s life, others contend that the benefits outweigh the drawbacks. In this essay, I am favor of risk-taking and I will illustrate its pros outweigh its drawbacks.
To begin with, taking risks can significantly impact one’ ...
The table and charts below give information on the police budget for 2017 and 2018 in one area of Britain. The table shows where the money came from and the charts show how it was distributed.
The table and charts demonstrate a comprehensive overview of the police budget in a specific area of Britain during 2017 to 2018. The first table illustrates the sources of subsidy, while the pie charts depict that the allocation of funds across different categories.
Overall, an upward trend was witnessed in each source of the police budget. It is evident that the largest proportion of funding was allocated to officers and staff salaries.
Examining the table more closely, funding originated fr ...
Some children spend hours every day on their smartphones.
Why is this the case? Do you think this is a positive or a negative development?
With the advent of modern technology, kids are inclined to immerse themselves in digital world than ever before. While some people argue that it is beneficial to our children, others contend it could have adverse impacts on their development. I am in favor of the latter, and I will illustrate the root causes and my personal opinion in the essay.
Advanced technology has significantly reshaped human behaviors and li ...
In the future all cars, buses, and trucks will be driverless. The only people traveling inside these vehicles will be passengers.
Do you think the advantages of driverless vehicles outweigh the disadvantages?
Self-driving is one of most prevalent technology integrating with artificial intelligence since individuals have always pursed more convenient lifestyles. While some people argue that driverless vehicles have drawbacks, others support their development. I am favor of the latter with three benefits and I will illustrate that pros outweigh its drawbacks in the essay.
On the one hand, self-driving vehicles are benefici ...