原创 Leetcode - Isomorphic Strings

Question Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the characters

原创 Leetcode - Binary Tree Paths

Question Given a binary tree, return all root-to-leaf paths. For example, given the following binary tree: 1 /

原创 Leetcode - Length of Last Word

Question Given a string s consists of upper/lower-case alphabets and empty space characters ’ ‘, return the length

原创 Leetcode - Longest Increasing Subsequence

Question Given an unsorted array of integers, find the length of longest increasing subsequence. For example, Gi

原创 全組合與全排列

問題 給定一個字符串(或者數組),列舉出其所有子序列字符串以及所有元素的全排列,並均按指定的排序規則輸出。 排序規則: 指標一:較短的字符串排在較長的字符串之前,即按字符串長度升序排列 指標二:長度相同的字符串按照字典順序排列

原创 Leetcode - Power of Two

Question Given an integer, write a function to determine if it is a power of two. Java Code //版本一:通過整數二進制位中1的個數來判

原创 Leetcode - Reverse Vowels of a String

Question Write a function that takes a string as input and reverse only the vowels of a string. Example Given s =

原创 Leetcode - Rectangle Area

Question Find the total area covered by two rectilinear rectangles in a 2D plane. Each rectangle is defined by its

原创 Leetcode - Contains Duplicate II

Question Given an array of integers and an integer k, find out whether there are two distinct indices i and j in th

原创 Leetcode - First Bad Version

Question You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest

原创 Leetcode - Move Zeroes

Question Given an array nums, write a function to move all 0’s to the end of it while maintaining the relative orde

原创 Leetcode - Add Digits

Question Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. Exa

原创 Leetcode - Contains Duplicate

Question Given an array of integers, find if the array contains any duplicates. Your function should return true if

原创 Leetcode - Lowest Common Ancestor of a Binary Search Tree

Question Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. Ac

原创 Leetcode - Invert Binary Tree

Question Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \