- 博客(13)
- 资源 (1)
- 收藏
- 关注
原创 数据结构与算法-排序(二)
数据结构与算法-排序(二) 接上篇,继续介绍归并排序与快速排序。三、简单排序算法简介3.1 归并排序 归并排序使用的是分治策略,核心思想也比较简单。要排序一个序列,首先从中间将序列一分为二,然后对划分的前后两个序列进行排序,再将排序好的序列合而为一,这样原有的序列就已有序了。 可见,归并排序的核心在于合并有序序列。以下图为例,有两个待合并有序序列 5, 6, 8, 9, 与...
2019-11-10 22:25:36
185
原创 数据结构与算法-排序(一)
数据结构与算法-排序(一) 排序算法有很多种,此处仅介绍五种最经典通用的排序算法:冒泡排序、插入排序、选择排序、归并排序、快速排序。篇幅有限,本篇仅介绍前三种。最好时间复杂度最坏时间复杂度平均时间复杂度稳定排序原地排序冒泡排序O(n)O(n^2)O(n^2)是是插入排序O(n)O(n^2)O(n^2)是是选择排序O(n^2)O...
2019-10-13 12:17:32
304
原创 数据结构与算法-链表list
数据结构与算法-链表list 数据元素的存储与组织方式有两种,分别是静态与动态。静态存储方式,如向量,数据空间整体创建或销毁,各个元素物理存储次序与逻辑次序严格一致,从而可支持高效的静态操作,如访问、查找等。而动态存储方式,各个元素的物理空间需动态的分配和回收,相邻元素的物理地址未必相邻,只是在逻辑上形成次序,从而可支持高效的动态操作,如添加、删除等。一、简介 链表(list)是采用...
2019-09-07 17:40:26
747
原创 9. 回文数_Palindrome Number
Palindrome NumberDetermine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.判断一个整数是否是回文数。回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数。题目来源:力扣(LeetCode)链接:...
2019-09-06 19:32:34
138
原创 8. 字符串转换整数 (atoi)_String to Integer (atoi)
String to Integer (atoi)Implement atoi which converts a string to an integer.The function first discards as many whitespace characters as necessary until the first non-whitespace character is found....
2019-09-06 19:30:44
271
原创 7. 整数反转_ Reverse Integer
Reverse IntegerGiven a 32-bit signed integer, reverse digits of an integer.给出一个 32 位的有符号整数,你需要将这个整数中每位上的数字进行反转。题目来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/reverse-integerExample 1:Input:...
2019-09-06 19:28:35
110
原创 6. Z 字形变换_ZigZag Conversion
ZigZag Conversion将一个给定字符串根据给定的行数,以从上往下、从左到右进行 Z 字形排列。题目来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/zigzag-conversionThe string “PAYPALISHIRING” is written in a zigzag pattern on a given numb...
2019-09-06 19:27:15
127
原创 5. 最长回文子串_Longest Palindromic Substring
Longest Palindromic SubstringGiven a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.给定一个字符串 s,找到 s 中最长的回文子串。你可以假设 s 的最大长度为 1000。题目来源:力扣(L...
2019-09-06 19:23:32
116
原创 4. 寻找两个有序数组的中位数_Median of Two Sorted Arrays
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))....
2019-09-06 19:19:18
94
原创 3. 无重复字符的最长子串_Longest Substring Without Repeating Characters
Longest Substring Without Repeating CharactersGiven a string, find the length of the longest substring without repeating characters.给定一个字符串,请你找出其中不含有重复字符的 最长子串 的长度。题目来源:力扣(LeetCode)链接:https://leetc...
2019-09-06 19:16:42
131
原创 2. 两数相加_Add Two Numbers
Add Two NumbersYou 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 numb...
2019-09-06 19:06:57
164
1
原创 1. 两数之和_Two Sum
Two SumGiven 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 th...
2019-09-06 19:02:58
98
原创 数据结构与算法-向量vector
数据结构与算法-向量vector 数组是一组具有相同类型的数据,存储在连续的内存空间中。一、简介 向量(vector)是数组的抽象与泛化,由一组元素按线性次序封装完成。很多语言中都有提供容器类,如C++ STL 中的 vector,Java 中的 ArrayList。与链表、栈、队列一样,向量属于线性表结构。二、部分操作 基于vector的算法有很多,此处简单记录几个有意...
2019-08-09 17:21:48
745
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人