2017年12月25日

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 a 阅读全文

posted @ 2017-12-25 21:34 夜的第八章 阅读(207) 评论(0) 推荐(0) 编辑

4 sum

摘要: Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array whic 阅读全文

posted @ 2017-12-25 19:54 夜的第八章 阅读(229) 评论(0) 推荐(0) 编辑

3 sum closest

摘要: Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. 阅读全文

posted @ 2017-12-25 15:53 夜的第八章 阅读(176) 评论(0) 推荐(0) 编辑

五大常用算法:分治、动态规划、贪心、回溯和分支界定

摘要: 分治算法 一、基本概念 在计算机科学中,分治法是一种很重要的算法。字面上的解释是“分而治之”,就是把一个复杂的问题分成两个或更多的相同或相似的子问题,再把子问题分成更小的子问题……直到最后子问题可以简单的直接求解,原问题的解即子问题的解的合并。这个技巧是很多高效算法的基础,如排序算法(快速排序,归并 阅读全文

posted @ 2017-12-25 10:22 夜的第八章 阅读(504) 评论(0) 推荐(0) 编辑

导航