- 博客(9)
- 收藏
- 关注
原创 LeetCode63
这是“不同路径” 的进阶问题:现在考虑网格中有障碍物。那样将会有多少条不同的路径从左上角到右下角?网格中的障碍物和空位置分别用 1 和 0 来表示。例如,如下所示在 3x3 的网格中有一个障碍物。[[0,0,0],[0,1,0],[0,0,0]]一共有 2 条不同的路径从左上角到右下角。注意: m 和 n 的值均不超过 100。下面我们首先分析一下这个题目:如图,如果有障...
2018-12-30 22:09:40
116
原创 Capacitated Facility Location Problem
Capacitated Facility Location Problem这次作业我使用了两种不同的算法,分别是贪心算法和模拟退火算法贪心算法贪心算法的思想很简单,因为顾客数量远远大于工厂数量,所以我们力求让每一个顾客都找到能承载其需求的具有最小运输成本的工厂。伪代码如下FOR each customer: loop: find the factory with the small...
2018-12-30 18:01:33
165
原创 leetcode 312. Burst Balloons
题目:Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by array nums. You are asked to burst all the balloons. If the you burst balloon i you will get num...
2018-12-09 20:05:52
100
原创 leetcode 字节跳动题目 朋友圈
There are N students in a class. Some of them are friends, while some are not. Their friendship is transitive in nature. For example, if A is a direct friend of B, and B is a direct friend of C, then ...
2018-12-02 23:08:15
1425
原创 LeetCode152 乘积最大子序列
题目:给定一个整数数组 nums ,找出一个序列中乘积最大的连续子序列(该序列至少包含一个数)。思路:本题是求最大乘积,是最大子段和的变种。最大乘积可以由正数正数和负数负数得到,因此,需要同时记录下最大值和最小值。状态转移方程:dp[i] = max(maxmnums[i],minmnums[i],dp[i-1])maxm = max(maxmnums[i],minmnums[i],n...
2018-11-26 00:09:53
151
原创 LeetCode 37. Sudoku Solver
题目:Write a program to solve a Sudoku puzzle by filling the empty cells.A sudoku solution must satisfy all of the following rules:Each of the digits 1-9 must occur exactly once in each row.Each of ...
2018-10-21 23:17:43
69
原创 leetcode-最小栈
题目:Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) – Push element x onto stack.pop() – Removes the element on top of the stack.top() – Get ...
2018-09-23 15:03:29
162
原创 LeetCode 4. Median of Two Sorted Arrays
There 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)).You may assume nums1 and n...
2018-09-16 21:29:11
109
原创 hello world
欢迎使用Markdown编辑器写博客本Markdown编辑器使用StackEdit修改而来,用它写博客,将会带来全新的体验哦:Markdown和扩展Markdown简洁的语法代码块高亮图片链接和图片上传LaTex数学公式UML序列图和流程图离线写博客导入导出Markdown文件丰富的快捷键快捷键加粗 Ctrl + B 斜体 Ctrl + I...
2018-09-16 16:53:19
79
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人