# 第五十一题 和为n 连续正数序列

51.和为n 连续正数序列。 题目：输入一个正数n，输出所有和为n 连续正数序列。 例如输入15，由于1+2+3+4+5=4+5+6=7+8=15，所以输出3 个连续序列1-5、4-6 和7-8。 代码如下： public static void findSeqSum(int sum) { int begin=1,end=2,mid=sum/2,curSum=begin+end; ...

# leetcode 刷题之路 95 N-Queens II

N皇后问题的变种，要求直接输出N皇后的解法数目。这道题可以在N-Queens I的基础上增加计数功能，在每求得一个成功的解时（行数为N时）使计数变量递增即可。题目不要求输出具体的解法，因此可以做一点优化，使用position数组用来表示皇后的位置，position[i]的值表示第i行的皇后所处的列，这样子省却字符串数组的开销同时判断是否合法的isValid函数也更加简洁。...

# leetcode 刷题之路 91 Pascal's Triangle

Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5, Return [ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] ]...

# leetcode 刷题之路 90 Sort Colors

Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue. Here, we will use the integers ...

# leetcode 刷题之路 89 Gray Code

The gray code is a binary numeral system where two successive values differ in only one bit. Given a non-negative integer n representing the total number of bits in the code, print the sequence of ...

# leetcode 刷题之路 88 Remove Duplicates from Sorted Array

Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate extra space for another array, you must do this in place with...

# leetcode 刷题之路 87 Swap Nodes in Pairs

Given a linked list, swap every two adjacent nodes and return its head. For example, Given 1->2->3->4, you should return the list as 2->1->4->3. Your algorithm should use only constant space. Y...

# leetcode 刷题之路 86 Balanced Binary Tree

Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never diffe...

# leetcode 刷题之路 85 Merge Two Sorted Lists

erge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. 合并两个有序链表，合并后的链表仍然有序。...

# leetcode 刷题之路 82 Partition List

Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the original relative order of the nodes in each of...

# leetcode 刷题之路 81 Populating Next Right Pointers in Each Node

Populate each next pointer to point to its next right node. 二叉树的结构体里增加了next指针，编写程序，将二叉树里每个节点的next指针指向它右边的节点。...

# 状态模式

199条 共10页1 2 3 4 5 ... 下一页 尾页
个人资料
• 访问：116996次
• 积分：3064
• 等级：
• 排名：第12507名
• 原创：199篇
• 转载：0篇
• 译文：0篇
• 评论：6条
博客专栏
 leetcode刷题之路 文章：92篇 阅读：42423
最新评论