- 博客(4)
- 收藏
- 关注
原创 leetcode 279:Perfect Squares 解题报告
问题描述:Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n.思路:给定一个正整数n,将其拆分成多个完全平方数之和的形式。本题类似于硬币找零问题,给出代码如下:/** * 给出一个整数n...
2018-07-18 11:06:31 132
原创 Leetcode:23. Merge k Sorted Lists 解题报告
问题描述:Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.题目很容易理解,就是之前合并两个链表的升级版本,难度稍有提高。提供两种方法:分治法:我们发现给定函数传入的参数为一个链表组成的数组,把合并所有数组的任务分解为多个子任务,每次合并一半的链表得到两...
2018-07-13 20:44:17 91
原创 Leetcode:21. Merge Two Sorted Lists 解题报告
问题描述:Merge 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.简单来说就是合并两个链表,链表中的元素的顺序仍然是从小到大排序:总体来说比较简单,直接上代码: pri...
2018-07-13 19:59:28 145
原创 Leetcode130 :Submission Detail解题报告
问题描述:Given a 2D board containing 'X' and 'O' (the letter O), capture all regions surrounded by 'X'.A region is captured by flipping all 'O's into 'X's in that surrounded region.解题思路:广度优先搜索,如果在边界发现一个‘O...
2018-07-13 17:17:30 184
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人