原创 【leetcode】24. Swap Nodes in Pairs

Given a linked list, swap every two adjacent nodes and return its head. You may not modify the values in the list's nod

原创 【leetcode】25. Reverse Nodes in k-Group

Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. k is a positive integ

原创 【leetcode】383. Ransom Note

Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function th

原创 【leetcode】263. Ugly Number

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

原创 【leetcode】204. Count Primes

Count the number of prime numbers less than a non-negative number, n. Example: Input: 10 Output: 4 Explanation: There

原创 【leetcode】240. Search a 2D Matrix II

Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: In

原创 【leetcode】894. All Possible Full Binary Trees

A full binary tree is a binary tree where each node has exactly 0 or 2 children. Return a list of all possible full bin

原创 【leetcode】513. Find Bottom Left Tree Value

Given a binary tree, find the leftmost value in the last row of the tree. Example 1: Input: 2 / \ 1 3 Out

原创 【leetcode】515. Find Largest Value in Each Tree Row

You need to find the largest value in each row of a binary tree. Example: Input: 1 / \ 3

原创 【leetcode】779. K-th Symbol in Grammar

On the first row, we write a 0. Now in every subsequent row, we look at the previous row and replace each occurrence of

原创 【leetcode】77. Combinations

Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. Example: Input: n = 4, k = 2

原创 【leetcode】3. Longest Substring Without Repeating Characters

Given a string, find the length of the longest substring without repeating characters. Example 1: Input: "abcabcbb" Ou

原创 【leetcode】48. Rotate Image

You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Note: You have to r

原创 【leetcode】784. Letter Case Permutation

Given a string S, we can transform every letter individually to be lowercase or uppercase to create another string.  Re

原创 229. Majority Element II

Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. Note: The algorithm should run