原创 206. Reverse Linked List--LeetCode Record

Reverse a singly linked list. /** * Definition for singly-linked list. * public class ListNode { * public

原创 237. Delete Node in a Linked List--LeetCode Record

Write a function to delete a node (except the tail) in a singly linked list, given only access to that node. Suppo

原创 13. Roman to Integer--LeetCode Record

Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. l

原创 242. Valid Anagram--LeetCode Record

Given two strings s and t, write a function to determine if t is an anagram of s. For example, s = “anagram”, t

原创 231. Power of Two--LeetCode Record

Given an integer, write a function to determine if it is a power of two. 水到家了! func isPowerOfTwo(n: Int) -> B

原创 202. Happy Number --LeetCode Record

Write an algorithm to determine if a number is “happy”. A happy number is a number defined by the following proces

原创 100. Same Tree--LeetCode Record

Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal

原创 104. Maximum Depth of Binary Tree--LeetCode Record

Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from

原创 349. Intersection of Two Arrays--LeetCode Record

Given two arrays, write a function to compute their intersection. Example: Given nums1 = [1, 2, 2, 1], nums2 =

原创 226. Invert Binary Tree--LeetCode Record

/** * Definition for a binary tree node. * public class TreeNode { * public var val: Int * public var

原创 326. Power of Three--LeetCode Record

Given an integer, write a function to determine if it is a power of three. Follow up: Could you do it without u

原创 263. Ugly Number--LeetCode Record

Write a program to check whether a given number is an ugly number. Ugly numbers are positive numbers whose prime f

原创 283. Move Zeroes--LeetCode Record

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

原创 235. Lowest Common Ancestor of a Binary Search Tree --LeetCode Record

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

原创 191. Number of 1 Bits--LeetCode Record

Write a function that takes an unsigned integer and returns the number of ’1’ bits it has (also known as the Hammi