12
返回列表 发新帖
楼主: kingzise
跳转到指定楼层
上一主题 下一主题
收起左侧

冲谷日记

🔗
 楼主| kingzise 2020-1-14 02:47:43 | 只看该作者
全局:
Maximize Capital (hard)
Given a set of investment projects with their respective profits, we need to find the most profitable projects. We are given an initial capital and are allowed to invest only in a fixed number of projects. Our goal is to choose projects that give us the maximum profit.
Input: Project Capitals=[0,1,2,3], Project Profits=[1,2,3,5], Initial Capital=0, Number of Projects=3
Output: 8
Algorithm:
Use two heaps. first put capital and it's index which is the project id into a minheap, based on the initial capital, choose all the projects that within the capital. Then put the project id and it's profits tuple into the maxheap and pop the maxheap. Then update the capital to see how much money we have now. Repeat this process for k times, where k is number of projects we can choose.
回复

使用道具 举报

🔗
 楼主| kingzise 2020-1-17 03:52:24 | 只看该作者
全局:
Given a string, find all of its permutations preserving the character sequence but changing case.
Input: "ab7c"
Output: "ab7c", "Ab7c", "aB7c", "AB7c", "ab7C", "Ab7C", "aB7C", "AB7C"

problem itself is not hard, it's just simply select and replace the alpha char like subsets. Tricky thing are:
How do you replace the lower case with the upper case?
We can use python swapcase() function. However, we just want to swap one single char at a time, we have to make ii to list, swap case, then join it back as string.


  1.       string = list(permutations[j])
  2.       if string.isnumeric():
  3.         continue
  4.       string = string.swapcase()
  5.       permutations.append(''.join(string))
复制代码
[i][/i]
回复

使用道具 举报

🔗
 楼主| kingzise 2020-1-22 07:31:30 | 只看该作者
全局:
Order-agnostic Binary Search (easy)
Ceiling of a Number (medium)
Next Letter (medium)
Number Range (medium)
Search in a Sorted Infinite Array (medium)

binary search tree刷起来还是很快,5道题上班刷完
回复

使用道具 举报

🔗
 楼主| kingzise 2020-3-11 11:56:23 | 只看该作者
全局:
2/20/2020                        937. Reorder Data in Log Files
2/21/2020                        408. Valid Word Abbreviation
2/22/2020                        56. Merge Intervals
2/24/2020                        64. Minimum Path Sum
2/27/2020                        91. Decode Ways
2/27/2020                        639. Decode Ways II
2/28/2020                        65. Valid Number
2/29/2020        3/10/2020                311. Sparse Matrix Multiplication
2/29/2020                        277. Find the Celebrity
3/3/2020                        1269. Number of Ways to Stay in
3/4/2020                        1. Two Sum
3/4/2020                        167. Two Sum II
3/4/2020                        1563. Shortest path to the destination(Lintcode)
3/6/2020                        1831 Array Summarization
3/6/2020                        1815. Threhold Alerts
3/6/2020                        1844 subarray sum equals k II
3/6/2020                        1836 Reaching Point
3/8/2020                        1833. pen box
3/8/2020                        50. Pow(x, n)
3/8/2020                        Fast Power
3/8/2020                        372. Super Pow
3/8/2020                        2. Add Two Numbers
3/9/2020                        369. Plus One Linked List
3/10/2020                        242. Valid Anagram
3/10/2020                        438. Find All Anagrams in a String
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号
隐私提醒:
  • ☑ 禁止发布广告,拉群,贴个人联系方式:找人请去🔗同学同事飞友,拉群请去🔗拉群结伴,广告请去🔗跳蚤市场,和 🔗租房广告|找室友
  • ☑ 论坛内容在发帖 30 分钟内可以编辑,过后则不能删帖。为防止被骚扰甚至人肉,不要公开留微信等联系方式,如有需求请以论坛私信方式发送。
  • ☑ 干货版块可免费使用 🔗超级匿名:面经(美国面经、中国面经、数科面经、PM面经),抖包袱(美国、中国)和录取汇报、定位选校版
  • ☑ 查阅全站 🔗各种匿名方法

本版积分规则

>
快速回复 返回顶部 返回列表