- 博客(7)
- 收藏
- 关注
原创 leetcode | 买股票的最佳时机Ⅱ
给定一个数组,它的第 i 个元素是一支给定股票第 i 天的价格。 设计一个算法来计算你所能获取的最大利润。你可以尽可能地完成更多的交易(多次买卖一支股票)。 注意:你不能同时参与多笔交易(你必须在再次购买前出售掉之前的股票)。 示例 1: 输入: [7,1,5,3,6,4] 输出: 7 解释: 在第 2 天(股票价格 = 1)的时候买入,在第 3 天(股票价格 = 5)的时候卖出, 这笔...
2018-07-19 15:00:12
124
原创 leetcode | 从排序数组中删除重复项
给定一个排序数组,你需要在原地删除重复出现的元素,使得每个元素只出现一次,返回移除后数组的新长度。 不要使用额外的数组空间,你必须在原地修改输入数组并在使用 O(1) 额外空间的条件下完成。 示例 1: 给定数组 nums = [1,1,2], 函数应该返回新的长度 2, 并且原数组 nums 的前两个元素被修改为 [1,2] 你不需要考虑数组中超出新长度后面的元素。 示例 2: ...
2018-07-18 19:52:26
165
原创 LeetCode 658. Find K Closest Elements
Given a sorted array, two integers k and x, find the k closest elements to x in the array. The result should also be sorted in ascending order. If there is a tie, the smaller elements are always prefe...
2018-06-03 23:55:44
192
原创 算法学习|ZOJ1045 HangOver
How far can you make a stack of cards overhang a table? If you have one card, you can create a maximum overhang of half a card length. (We're assuming that the cards must be perpendicular to the table...
2018-05-31 00:11:45
224
原创 算法学习|ZOJ1070 Bode Plot
ProblemConsider the AC circuit below. We will assume that the circuit is in steady-state. Thus, the voltage at nodes 1 and 2 are given by v1 = VS cos ω t and v2 = VR cos ( ω t + θ ) where VS is the v...
2018-05-30 20:52:14
538
原创 算法学习笔记|整数与浮点数输出问题
#include <iostream> using namespace std; int main() { printf("%d\n", 1+2); printf("%d\n", 3-4); printf("%d\n", 5*6); printf("%d\n", 8/5); printf("%f\n", 8/5); printf(
2018-05-30 17:07:42
327
1
原创 进程与线程的关系总结
进程process 线程thread 计算机的核心是CPU,它承担了所有的计算任务。它就像一座工厂,时刻在运行。 假定工厂的电力有限,一次只能供给一个车间使用。也就是说,一个车间开工的时候,其他车间都必须停工。背后的含义就是,单个CPU一次只能运行一个任务。 进程就好比工厂的车间,它代表CPU所能处理的单个任务。任一时刻,CPU总是运行一个进程,其他进程处于非运行状态。
2016-03-24 09:34:02
283
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人