原创 (Java)LeetCode-48. Rotate Image

You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Follow up: Could

原创 (Java)LeetCode-52. N-Queens II

Follow up for N-Queens problem. Now, instead outputting board configurations, return the total number of distinct so

原创 (Java)LeetCode-50. Pow(x, n)

Implement pow(x, n). 這道題最慢時間複雜度也是O(n),快一些的是O(logn),主要是將n考慮爲二進制的形式,某一位是1的話,就乘上相應的次方數即可。代碼如下: public class Solution {

原创 (Java)LeetCode-49. Group Anagrams

Given an array of strings, group anagrams together. For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"], 

原创 (Java)LeetCode-67. Add Binary

Given two binary strings, return their sum (also a binary string). For example, a = "11" b = "1" Return "100". 這道題也

原创 (Java)LeetCode-64. Minimum Path Sum

Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum

原创 (Java)LeetCode-39. Combination Sum

Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate

原创 (Java)LeetCode-36. Valid Sudoku

Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules. The Sudoku board could be partially filled

原创 (Java)LeetCode-43. Multiply Strings

Given two numbers represented as strings, return multiplication of the numbers as a string. Note: The numbers can be

原创 (Java)LeetCode-37. Sudoku Solver

Write a program to solve a Sudoku puzzle by filling the empty cells. Empty cells are indicated by the character '.'.

原创 (Java)LeetCode-47. Permutations II

Given a collection of numbers that might contain duplicates, return all possible unique permutations. For example,

原创 (Java)LeetCode-34. Search for a Range

Given a sorted array of integers, find the starting and ending position of a given target value. Your algorithm's ru

原创 (Java)LeetCode-42. Trapping Rain Water

Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water i

原创 (Java)LeetCode-51. N-Queens

The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other

原创 (Java)LeetCode-44.Wildcard Matching

Implement wildcard pattern matching with support for '?' and '*'. '?' Matches any single character. '*' Matches any se