C++
冬风噬雪
这个作者很懒,什么都没留下…
展开
-
LeetCode--4. Median of Two Sorted Arrays
4. Median of Two Sorted ArraysThere are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).E原创 2017-04-27 08:05:51 · 227 阅读 · 0 评论 -
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. Given an integer n, return all distinct solutions to the n-queens puzzle.Each s原创 2017-06-27 10:12:24 · 193 阅读 · 0 评论 -
LeetCode--104. Maximum Depth of Binary Tree
Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node./** * Definition for a binary tree node.原创 2017-07-05 16:29:20 · 217 阅读 · 0 评论 -
LeetCode--47. Permutations II
Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example, [1,1,2] have the following unique permutations:[ [1,1,2], [1,2,1], [2,1,1]]解决代码原创 2017-06-26 08:47:17 · 247 阅读 · 0 评论 -
LeetCode--100. Same Tree
Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value. 代码:/** * Definit原创 2017-07-04 10:34:49 · 201 阅读 · 0 评论 -
LeetCode--112. Path Sum
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example: Given the below binary tree and sum = 2原创 2017-07-13 10:24:02 · 258 阅读 · 0 评论 -
LeetCode--77. Combinations
Given two integers n and k, return all possible combinations of k numbers out of 1 … n.For example, If n = 4 and k = 2, a solution is:[ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4],]解决代码:clas原创 2017-07-03 08:19:34 · 173 阅读 · 0 评论 -
LeetCode--52. N-Queens II
Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.解决方法:class Solution {public: int totalNQueens(int n) { int count原创 2017-07-03 08:15:56 · 214 阅读 · 0 评论 -
LeetCode--216. Combination Sum III
Find all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used and each combination should be a unique set of numbers.Example 1:Input: k = 3, n =原创 2017-07-03 08:02:21 · 167 阅读 · 0 评论 -
LeetCode--46. Permutations
Given a collection of distinct numbers, return all possible permutations.For example, [1,2,3] have the following permutations:[ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1]]解题代码:c原创 2017-06-21 19:49:55 · 175 阅读 · 0 评论 -
LeetCode--40. Combination Sum II
Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.Each number in C may only be used once in the combination.No原创 2017-06-20 10:01:17 · 193 阅读 · 0 评论 -
LeetCode--111. Minimum Depth of Binary Tree
Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.代码:/** * Definition for a binary tree node原创 2017-07-06 14:25:00 · 213 阅读 · 0 评论