Egbert Lin's Blog

“Life is not a race, but a journey to be savoured each step of the way” by Brian Dyson

8. Length of Last Word

Question:

Given a string s consists of some words separated by spaces, return the length of the last word in the string. If the last word does not exist, return 0.

A word is a maximal substring consisting of non-space characters only.

Read more »

20. Valid Parentheses

Question:

Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.

An input string is valid if: 1. Open brackets must be closed by the same type of brackets. 2. Open brackets must be closed in the correct order.

Read more »

13. Roman to Integer

Question:

Roman numerals are represented by seven different symbols: \(I\), \(V\), \(X\), \(L\), \(C\), \(D\) and M.

Symbol  Value
\(I\)       1
\(V\)      5
\(X\)      10
\(L\)       50
\(C\)      100
\(D\)      500
\(M\)        1000

Read more »

Command line: "hexo d" and you got error message: Please tell me who you are.

Full error message info:

Please tell me who you are.

Run

git config --global user.email “you@example.com”
git config --global user.name “Your Name”

to set your account’s default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got ...)
error: src refspec HEAD does not match any.
error: failed to push some refs to(your ...github.io)

Read more »

7. Reverse Integer

Question:

Given a 32-bit signed integer, reverse digits of an integer.

Note: Assume we are dealing with an environment that could only store integers within the 32-bit signed integer range: [−2^31, 2^31 − 1]. For the purpose of this problem, assume that your function returns 0 when the reversed integer overflows.

Read more »

1. Two Sum

Question:

Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.

You may assume that each input would have exactly one solution, and you may not use the same element twice.

You can return the answer in any order.

Read more »

Tower of Hanoi

Let's realize how does tower of hanoi works and how to use recursive function to implement it!!!

The Tower of Hanoi is a mathematical game or puzzle, it's a classical problem during your CSIE studies.

First, the demonstration of process(3 disks and 3 rods) as below[1]: animation

Read more »