![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法题
chenh297
中山大学_15级软件工程专业_计算机应用方向学生
展开
-
Longest Palindromic Substring 解法
Longest Palindromic Substring 解法 第三周题目 难度:Media LeetCode题号:5题目Description: Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.原创 2017-09-21 11:21:58 · 130 阅读 · 0 评论 -
最小和 解法
最小和 解法 第十周题目 难度:Media Sicily题号:期中考1005题目Description: 从数列A[0], A[1], A[2], …, A[N-1]中选若干个数,要求对于每个i(0<=i< N-1),A[i]和A[i+1]至少选一个数,求能选出的最小和. 1 <= N <= 100000, 1 <= A[i] <= 1000 请为下面的So原创 2017-12-08 10:02:49 · 136 阅读 · 0 评论 -
Course Schedule III 解法
Course Schedule III 解法 第 14 周题目 难度:Hard LeetCode题号:630题目Description: There are n different online courses numbered from 1 to n. Each course has some duration(course length) t and closed on d原创 2017-12-18 19:45:06 · 301 阅读 · 0 评论 -
Insert Delete GetRandom O(1) - Duplicates allowed 解法
Insert Delete GetRandom O(1) - Duplicates allowed 解法 第 16 周题目 难度:Hard LeetCode题号:381题目Description: Design a data structure that supports all following operations in average O(1) time. N原创 2018-01-21 10:24:12 · 193 阅读 · 0 评论 -
Merge k Sorted Lists 解法
Merge k Sorted Lists 解法 第 17 周题目 难度:Hard LeetCode题号:23题目Description: Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.思考 这道题目在分布式系统中非常常见,来原创 2018-01-21 10:27:09 · 147 阅读 · 0 评论 -
Jump Game II 解法
Jump Game II 解法 第 18 周题目 难度:Hard LeetCode题号:45题目Description: Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array原创 2018-01-21 10:29:32 · 1089 阅读 · 0 评论 -
Redundant Connection II 解法
Redundant Connection II 解法 第 19 周题目 难度:Hard LeetCode题号:685题目Description: In this problem, a rooted tree is a directed graph such that, there is exactly one node (the root) for which all othe原创 2018-01-21 10:33:45 · 374 阅读 · 0 评论 -
Reverse Pairs 解法
Reverse Pairs 解法 第 20 周题目 难度:Hard LeetCode题号:493题目Description: Given an array nums, we call (i, j) an important reverse pair if i < j and nums[i] > 2*nums[j]. You need to return the num原创 2018-01-21 10:37:22 · 477 阅读 · 0 评论 -
Cherry Pickup 解法
Cherry Pickup 解法 第 21 周题目 难度:Hard LeetCode题号:741题目Description: In a N x N grid representing a field of cherries, each cell is one of three possible integers.0 means the cell is empty, so yo原创 2018-01-21 11:50:16 · 1128 阅读 · 0 评论 -
Convert Sorted List to Binary Search Tree 解法
Convert Sorted List to Binary Search Tree 解法 第 13 周题目 难度:Media LeetCode题号:109题目Description: Given a singly linked list where elements are sorted in ascending order, convert it to a height ba原创 2017-12-16 16:08:40 · 200 阅读 · 0 评论 -
最近的0 解法
最近的0 解法 第九周题目 难度:Hard Sicily题号:期中考1003题目Description: 输入一个N*M的01矩阵A,对矩阵的每个位置,求至少经过多少步可以到达一个0. 每一步可以往上下左右走一格. 请为下面的Solution类实现解决这一问题的函数nearestZero,函数参数A为给出的01矩阵,A的行数和列数均不大于100. 函数的返回值是问题的原创 2017-12-07 11:56:23 · 212 阅读 · 0 评论 -
Longest Substring Without Repeating Characters 解法
Longest Substring Without Repeating Characters 解法 第二周题目 难度:Media LeetCode题号:3题目Description: Given a string, find the length of the longest substring without repeating characters. Exampl原创 2017-09-16 11:29:57 · 148 阅读 · 0 评论 -
Split Array into Consecutive Subsequences 解法
Split Array into Consecutive Subsequences 解法 第七周题目 难度:Media LeetCode题号:659题目Description: You are given an integer array sorted in ascending order (may contain duplicates), you need to split原创 2017-10-26 12:12:30 · 304 阅读 · 0 评论 -
Add Two Numbers 解法
Add Two Numbers 解法 第一周题目 难度:Media LeetCode题号:2题目Description: You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each原创 2017-10-30 15:34:42 · 158 阅读 · 0 评论 -
ZigZag Conversion 解法
ZigZag Conversion 解法 第四周题目 难度:Media LeetCode题号:6题目Description: The string “PAYPALISHIRING” is written in a zigzag pattern on a given number of rows like this: (you may want to display this p原创 2017-10-30 16:27:12 · 286 阅读 · 0 评论 -
Integer to Roman 解法
Integer to roman转载 2017-09-10 14:57:02 · 286 阅读 · 0 评论 -
Letter Combinations of a Phone Number 解法
Letter Combinations of a Phone Number 解法 第11周题目 难度:Media LeetCode题号:17题目Description: Given a digit string, return all possible letter combinations that the number could represent. A map原创 2017-12-13 17:30:23 · 272 阅读 · 0 评论 -
Swap Nodes in Pairs 解法
Swap Nodes in Pairs 解法 第 12 周题目 难度:Media LeetCode题号:24题目Description: Given a linked list, swap every two adjacent nodes and return its head. For example, Given 1->2->3->4, you should原创 2017-12-14 10:27:02 · 113 阅读 · 0 评论 -
Merge Two Binary Trees 解法
Merge Two Binary Trees 解法 第八周题目 难度:Easy LeetCode题号:617题目Description: Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are over原创 2017-12-05 20:24:25 · 218 阅读 · 0 评论 -
BFS 解法
BFS 解法 第15周题目 难度:MEDIA 题目:无权图BFS实现思考 用队列保存每次要访问的节点,然后每次拿出一个,如果当前这个是目标节点,就打印出距离,然后退出;如果不是,就把该节点周围的且没有被访问过的节点压入一个新队列。当此时的队列都拿完后,对新队列进行相同的操作代码#include <iostream>#include <vector>#include <qu原创 2018-01-08 21:40:23 · 324 阅读 · 0 评论