![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法与数据结构
开发者如是说
这个作者很懒,什么都没留下…
展开
-
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 · 568 阅读 · 1 评论 -
数据结构与算法回顾-3:二叉查找树
1、概念二叉查找树(BST) 是一种二叉树,它的每个结点都只有左右两个链接,分别指向自己的左子结点和右子结点,并且每个结点都大于其左子树中的任意结点的键,并且小于任意右子树的任意结点的键。(注意和堆的区别)2、代码实现2.1 使用循环的方式来进行查找和插入下面的代码中使用了循环的方式来将指定的键值对插入到表中。缺点:相比于使用递归的方式这里的代码显得比较冗长,而且在循环之中没办法统计和更新...原创 2019-02-26 00:06:26 · 217 阅读 · 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 · 249 阅读 · 0 评论 -
数据结构与算法回顾-1:算法的度量和基本数据结构
1、数据结构数据结构是相互之间存在一种或多种关系的数据的集合。1.1 三要素数据结构三要素是:1.数据的逻辑结构;2.数据的物理结构;3.数据的运算。数据结构是相互之间存在一种或多种特定关系的数据元素的集合。1.1.1 逻辑结构分为线性结构和非线性结构,线性结构:线性表、栈、队列非线性结构:树、图、集合1.1.2 存储结构即物理结构,分四种(存储数据时不只要存储元素的值...原创 2019-02-25 23:33:04 · 257 阅读 · 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->4Output: 1-...原创 2019-01-25 00:58:25 · 557 阅读 · 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 · 548 阅读 · 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 · 553 阅读 · 0 评论 -
LeetCode-Easy-013-Roman to Integer
描述Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.Symbol ValueI 1V 5X 10L 50C 100D ...原创 2019-01-24 19:16:30 · 587 阅读 · 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: 121Output: trueExample 2:Input: -121Output: falseExplana...原创 2019-01-24 18:44:26 · 588 阅读 · 0 评论 -
LeetCode-Easy-007-Reverse-integer
描述Given a 32-bit signed integer, reverse digits of an integer.Example 1:Input: 123Output: 321Example 2:Input: -123Output: -321Example 3:Input: 120Output: 21Note:Assume we are dealing wi...原创 2019-01-24 12:52:05 · 599 阅读 · 0 评论 -
数据结构与算法回顾-4:平衡查找树
二叉树虽然能解决查找的问题,但是在某些情况下,比如当任意相邻的两个元素之间是按照升序或者降序插入的话,那么得到的树将是一个链表的形状。当然这只是一种极端的情况,只是用来说明,树的形状对二叉查找的效率有很大的影响。这里的平衡二叉树能够让树保持完美的平衡,不会出现极端的成为链表等,而且我们也会试图去保持树的完美平衡。它实现这个平衡目的的方式是:对于 3-结点,如果再向其插入数据,就会使其变成 4-...原创 2019-02-26 00:23:23 · 276 阅读 · 0 评论