
算法
allenayo
这个作者很懒,什么都没留下…
展开
-
Add Tow Numbers
TopicYou are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and re...原创 2018-11-20 17:38:30 · 180 阅读 · 0 评论 -
Longest Substring Without Repeating Characters
TopicGiven a string, find the length of the longest substring without repeating characters.ExampleInput: "abcabcbb"Output: 3 Explanation: The answer is "abc", with the length of 3. Solution方案...原创 2018-11-20 23:49:58 · 145 阅读 · 0 评论 -
选择排序
一、 算法思路首先找到数组最小的元素,将它和数组的第一个元素交换位置。然后在数组剩下的元素当中找到最小的元素,将它和数组的第二个元素交换位置…以此类推,直到整个数组排完序。二、时间复杂度对于长度为nnn的数组,选择排序需要大约n2n^2n2次比较和nnn次交换,所以时间复杂度为O(n2)O(n^2)O(n2)。以一组长度为6的整型数组为例,如下图所示:其中iii表示交换的次数,共6次。...原创 2018-11-23 16:41:07 · 151 阅读 · 0 评论 -
Tow Sum
TopicGiven an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use the ...原创 2018-11-19 20:51:21 · 196 阅读 · 0 评论 -
Median Of Two Sorted Arrays
题目梗概:找出两个已排序数组的中位数。解题思路: 首先了解什么是中位数?中位数是指一组有序数据中居于中间位置的数。对于奇数个数据的一组有序数据而言,中位数是居于中间位置的数,如1、2、3、4、5中,中位数是3。对于偶数个数据的一组有序数据而言,中位数是居于中间位置的两个数的平均数,如2、4、6、8、10、12中,中位数为6和8的平均数7。&nb...原创 2019-04-10 17:17:52 · 272 阅读 · 0 评论 -
Longest Palindromic Substring
题目梗概:找出指定字符串中最长的回文子串。解题思路: 最简单的方法应该是找出指定字符串的所有子串,从最长的子串开始判断是否是回文字符串,是则直接返回该子串,不是则继续对剩下的子串进行判断,直到找到回文字符串为止。 由于回文字符串的特点是“从中心到两端的字符一一对应”。主要有以下两种形式,对于单核回文...原创 2019-04-11 15:54:02 · 158 阅读 · 0 评论