我的思路:
定义一个字典,
开始沥遍list
如果指向的数字 在字典里出现数 不等于1, 就让value=1(等于一,就加一)
然后沥遍字典,找到value等于1的位置,再读出key的数字
结果:速度太慢
solution:
没看到空间复杂度o(1)
异或逻辑运算:
待更新
心が強い人なれるように
我的思路:
定义一个字典,
开始沥遍list
如果指向的数字 在字典里出现数 不等于1, 就让value=1(等于一,就加一)
然后沥遍字典,找到value等于1的位置,再读出key的数字
结果:速度太慢
solution:
没看到空间复杂度o(1)
异或逻辑运算:
待更新
题目很简单,但是有几个地方需要注意:
我的思路:
首先假设第一天肯定买进,然后从第二天开始看
情况一:如果第二天的价格低于第一天,那就以第二天的买价为准
以此类推
情况二:如果盈利天时,就开始计算之后每一天的差价,并记录最高价
每次发现有情况二发生,比较当前差价和上次计算差价,取其最大值
结论:8800ms 问题在情况2判断是 时间复杂度在o(n)级别
对比参考答案
发现盈利天时,将当天受益和当前最佳受益(初始值0,即平仓线)直接对比
如果当天收益更高,直接更新最佳受益计数
结论:60ms
总结:
条件一,找买入时机,条件二,找卖出时机
Background:
It is insane to build a table describing every attribute for huge a lot of entities, because there are many spareness in it.
Definition:
1. entity: the things to be described
2. attribute: ways or data to desribe the entity
3. value: the value of attribute
then:
1. a row is a fact
2. attribute and value pair is a fact describing an entity
In detail:
the entity is also like a array, which includes, in the clinical example, name and brief descpriton.
the attribute is cited from attribute definition table as a foreign key.