Memory Allocation

  • Home

  • Tags

  • Categories

  • Archives

  • Commonweal 404

  • Search

记账Side Project (一)

Posted on 2018-06-03 | Edited on 2018-12-19 | In thoughts |

想法

很久之前, 我就有记账的想法, 可是当时一直因为懒, 没有对记账的这个事情上心, 久而久之, 记账这个东西就成为了我心头的一个想完成但是有一直没有完成的一个任务和想法. 现在突然再把这个东西提出来, 主要是我自己有几个痛点, 希望能够通过记账的方式解决. 第一, 虽然我现在挣的奖学金有一千多美金一个月, 但是不足以覆盖生活开支, 很惭愧, 仍然需要家里的接济. 但是, 每当我母亲问起来一个月需要接济我多少, 我常常拿不准数额, 因为确实没有对一个月的花费有一个宏观的认识. 第二, 作为一个电子产品爱好者和乐高爱好者, 支撑这些爱好是需要钱的, 在决定出手购买这些东西的时候, 时常拿捏不准当前的存款是否可以支撑我的消费. 我向往有一个类似于财务管家一样的东西, 去告诉我, 我这个月的理财收益有多少, 能够被我自由支配的有多少. 第三, 就是帮助自己建立存款目标, 为将来组建家庭时能够有一定基础.

Read more »

Range Addition

Posted on 2018-05-28 | Edited on 2018-12-19 | In interview questions |

370. Range Addition

Assume you have an array of length n initialized with all 0’s and are given k update operations.
Each operation is represented as a triplet: [startIndex, endIndex, inc] which increments each element of subarray A[startIndex ... endIndex] (startIndex and endIndex inclusive) with inc.
Return the modified array after all k operations were executed.

给一个length, 这是要返回的数组的长度, 初始的时候所有值为0. 还有一个n*3的数组, 每一行有3个数, 分别代表了start, end和inc. 我们需要更新我们的结果数组, 从start 到 end.

Read more »

Wiggle Sort

Posted on 2018-05-28 | Edited on 2018-12-19 |

280. Wiggle Sort

Given an unsorted array nums, reorder it in-place such that nums[0] <= nums[1] >= nums[2] <= nums[3]....

将数组in-place进行wiggle排序. Wiggle排序的意思是, nums[0] <= nums[1] >= nums[2] <= nums[3]....

Read more »

Rotate Array

Posted on 2018-05-27 | Edited on 2018-12-19 | In interview questions |

189. Rotate Array

Given an array, rotate the array to the right by k steps, where k is non-negative.

给一个数组和一个整数k, 把数组往右移k位. 需要注意的是k有可能比数组的长度要大

Read more »

Third Maximum Number

Posted on 2018-05-27 | Edited on 2018-12-19 |

414. Third Maximum Number

Given a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time complexity must be in O(n).

给一个数组, 求数组内第三大的数, 如果不存在, 则返回最大的数. 题目还有一个特别的要求, 时间复杂度控制在$O(n)$, 意味着, 不能排序.

Read more »

K-diff Pairs in an Array

Posted on 2018-05-27 | Edited on 2018-12-19 | In interview questions |

532. K-diff Pairs in an Array

Given an array of integers and an integer k, you need to find the number of unique k-diff pairs in the array. Here a k-diff pair is defined as an integer pair (i, j), where i and j are both numbers in the array and their absolute difference is k.

给一个数组, 返回所有的k-diff组合.

Read more »

Shortest Unsorted Continuous Subarray

Posted on 2018-05-27 | Edited on 2018-12-19 | In interview questions |

581. Shortest Unsorted Continuous Subarray

Given an integer array, you need to find one continuous subarray that if you only sort this subarray in ascending order, then the whole array will be sorted in ascending order, too.
You need to find the shortest such subarray and output its length.

给一个数组, 返回一个最短子数组, 使这个子数组排序后, 原数组是一个升序数组.

Read more »

Can Place Flower

Posted on 2018-05-27 | Edited on 2018-12-19 | In interview questions |

605. Can Place Flower

Suppose you have a long flowerbed in which some of the plots are planted and some are not. However, flowers cannot be planted in adjacent plots - they would compete for water and both would die.
Given a flowerbed (represented as an array containing 0 and 1, where 0 means empty and 1 means not empty), and a number n, return if n new flowers can be planted in it without violating the no-adjacent-flowers rule.

给一个数组, 代表花圃, 和一个数字n表示要种的画的数量. 问花圃能不能种下这么多的花

花圃有0和1组成, 0表示空位, 1表示已经有花种在那里了.
如果要往一个空位里面种花, 需要满足一个条件: 该位置左右都是空的.

Read more »

12345
Jiakuan Li

Jiakuan Li

雷霆雨露,俱是天恩

39 posts
6 categories
28 tags
GitHub Twitter
© 2019 Jiakuan Li