Chen's blog

Notes on building polished Apple apps.

Swift, SwiftUI, tooling, app architecture, and the small product details that make software feel considered.

[28] Implement strStr()

Problem: 28. Implement strStr() Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of …

3 min read #Algorithm #Array

[257] Binary Tree Paths

Problem: 257. Binary Tree Paths Given a binary tree, return all root-to-leaf paths. For example, given the following binary tree: 1 / 2 3 5 All …

1 min read #Algorithm #Array

[018] Length Of Last Word

Problem Given a string s consists of upper/lower-case alphabets and empty space characters ’ ‘, return the length of last word in the string. …

1 min read #Algorithm #Array

Notes on singly linked lists

Cyclic singly linked lists — linked lists that contain a loop — come up in a lot of interview questions. This post is a roundup, partly for reference and …

5 min read #Array #C++11

[151] Reverse Words in a String

Problem: Reverse Words in a String Given an input string s, reverse the string word by word. For example, given s = “the sky is blue”, return …

1 min read #Array #C++11

Two Sum

This post covers two LeetCode problems: Two Sum I and Two Sum II. Problem 1: 1. Two Sum Given an array of integers, find two numbers such that they add up …

3 min read #Array #C++11