qingcheng奕 |
|
||
2014年6月19日
摘要:
https://oj.leetcode.com/problems/trapping-rain-water/模拟题,计算出在凹凸处存水量。对于一个位置 i ,分别计算出它左边的最大值 left (从左扫描一遍), 右边的最大值 right(从右扫描一遍) 。找left right中的最小值,如果大于 ... 阅读全文
摘要:
https://oj.leetcode.com/problems/triangle/一个三角形,类似于杨辉三角的形状,求从上到下最小的路径和,但走每一步都得是相邻的。动态规划,从下到上一层层来。sum[i] = min{sum[i]+triangle[i][j],sum[i+1]+triangle[... 阅读全文
摘要:
https://oj.leetcode.com/problems/sqrtx/求一个数的开方,二分查找一个数,直到这个数的平方 - target 小于 0.001。但这道题出的不好,返回值竟然是 int ,脑洞太大了。class Solution {public: int sqrt(int x... 阅读全文
摘要:
https://oj.leetcode.com/problems/simplify-path/对linux路径的规范化,属于字符串处理的题目。细节很多。#include #include using namespace std;class Solution {public: string si... 阅读全文
|
Copyright © 2024 qingcheng奕
Powered by .NET 8.0 on Kubernetes |