
算法与数据结构
开发者如是说
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
LeetCode-Easy-001-Two sum
描述 Given 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 sam...原创 2019-01-24 12:40:03 · 611 阅读 · 1 评论 -
数据结构与算法回顾-3:二叉查找树
1、概念 二叉查找树(BST) 是一种二叉树,它的每个结点都只有左右两个链接,分别指向自己的左子结点和右子结点,并且每个结点都大于其左子树中的任意结点的键,并且小于任意右子树的任意结点的键。(注意和堆的区别) 2、代码实现 2.1 使用循环的方式来进行查找和插入 下面的代码中使用了循环的方式来将指定的键值对插入到表中。缺点:相比于使用递归的方式这里的代码显得比较冗长,而且在循环之中没办法统计和更新...原创 2019-02-26 00:06:26 · 291 阅读 · 0 评论 -
数据结构与算法回顾-2:排序算法小结
在下面的排序算法中会使用到的方法: protected static void exchange(Comparable[] arr, int fromPos, int toPos) { Comparable temp = arr[fromPos]; arr[fromPos] = arr[toPos]; arr[toPos] = temp; ...原创 2019-02-25 23:48:49 · 321 阅读 · 0 评论 -
数据结构与算法回顾-1:算法的度量和基本数据结构
1、数据结构 数据结构是相互之间存在一种或多种关系的数据的集合。 1.1 三要素 数据结构三要素是:1.数据的逻辑结构;2.数据的物理结构;3.数据的运算。 数据结构是相互之间存在一种或多种特定关系的数据元素的集合。 1.1.1 逻辑结构 分为线性结构和非线性结构, 线性结构:线性表、栈、队列 非线性结构:树、图、集合 1.1.2 存储结构 即物理结构,分四种(存储数据时不只要存储元素的值...原创 2019-02-25 23:33:04 · 337 阅读 · 0 评论 -
LeetCode-Easy-021-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. Example: Input: 1->2->4, 1->3->4 Output: 1-...原创 2019-01-25 00:58:25 · 653 阅读 · 0 评论 -
LeetCode-Easy-020-Valid Parentheses
描述 Given a string containing just the characters ‘(’, ‘)’, ‘{’, ‘}’, ‘[’ and ‘]’, determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of ...原创 2019-01-25 00:14:32 · 621 阅读 · 0 评论 -
LeetCode-Easy-014-Longest Common Prefix
描述 Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string “”. Example 1: Input: ["flower","flow","flight"] Output: ...原创 2019-01-24 23:56:53 · 604 阅读 · 0 评论 -
LeetCode-Easy-013-Roman to Integer
描述 Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V 5 X 10 L 50 C 100 D ...原创 2019-01-24 19:16:30 · 681 阅读 · 0 评论 -
LeetCode-Easy-009-Palindrome Number
描述 Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward. Example 1: Input: 121 Output: true Example 2: Input: -121 Output: false Explana...原创 2019-01-24 18:44:26 · 655 阅读 · 0 评论 -
LeetCode-Easy-007-Reverse-integer
描述 Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Output: 321 Example 2: Input: -123 Output: -321 Example 3: Input: 120 Output: 21 Note: Assume we are dealing wi...原创 2019-01-24 12:52:05 · 646 阅读 · 0 评论 -
数据结构与算法回顾-4:平衡查找树
二叉树虽然能解决查找的问题,但是在某些情况下,比如当任意相邻的两个元素之间是按照升序或者降序插入的话,那么得到的树将是一个链表的形状。当然这只是一种极端的情况,只是用来说明,树的形状对二叉查找的效率有很大的影响。 这里的平衡二叉树能够让树保持完美的平衡,不会出现极端的成为链表等,而且我们也会试图去保持树的完美平衡。 它实现这个平衡目的的方式是:对于 3-结点,如果再向其插入数据,就会使其变成 4-...原创 2019-02-26 00:23:23 · 345 阅读 · 0 评论