
数据结构与算法
Bright's Dream
计算机专业本科生,web技术爱好者
展开
-
数据结构与算法:迪杰斯特拉和prim TypeScript实现
迪杰斯特拉算法迪杰斯特拉算法用于求图中的单源最短路劲,所谓单源最短路劲,是指从图中的某一个顶点出发,这个顶点到图中的其它节点的最短路劲。迪杰斯特拉算法的主要思想如下:将图中的节点分成两个集合:一个集合表示已经求出最短路劲的顶点集合,另一个集合表示还未求出到起点最短距离的顶点集合,初始未求出集合为空。从未求出集合中选取一个距离最小的节点,并将其加入到已求出集合中更新未求出集合中顶点到起点...原创 2019-04-16 13:55:59 · 384 阅读 · 0 评论 -
LeetCode题解:Merge Intervals
题目描述Given a collection of intervals, merge all overlapping intervals.Example 1:Input: [[1,3],[2,6],[8,10],[15,18]]Output: [[1,6],[8,10],[15,18]]Explanation: Since intervals [1,3] and [2,6] overla...原创 2019-05-02 10:06:14 · 158 阅读 · 0 评论 -
LeetCode 题解:Unique Path
题目描述A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach t...原创 2019-05-03 12:19:46 · 209 阅读 · 0 评论 -
LeetCode 题解:Minimum Path Sum
动态规划算法,代码如下,解释查看我的另一篇博客,两个题非常相似:/** * @param {number[][]} grid * @return {number} */var minPathSum = function(grid) { if(grid.length == 0) return 0; var a = new Array(grid.length); var m = ...原创 2019-05-03 12:44:57 · 151 阅读 · 0 评论 -
LeetCode题解:Edit Distance
题目Given two words word1 and word2, find the minimum number of operations required to convert word1 to word2.You have the following 3 operations permitted on a word:Insert a characterDelete a char...原创 2019-05-04 10:50:07 · 219 阅读 · 0 评论 -
LeetCode题解:Sort Colors
题目Sort ColorsMedium1550148FavoriteShareGiven an array with n objects colored red, white or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the ord...原创 2019-05-04 12:31:04 · 121 阅读 · 0 评论