砍出一个美丽的row
这个row美丽的条件: 全递增, 全递减, 或者先递增在递减, 全相等是不行的.
求最少砍树次数 让它变得美丽
Case1: 99999 -> output 4次
case2: 3 17 4 12 5 6 2 1 砍掉17和5 -> ouput 2
case3: 9 8 7 12 3 99 砍掉 9 8 和 99 -> output 3
把email变成unread 有三种点击操作
\1. 打开unread email
2.跳出 已经read的email
3.如果已经进入read email 可以前后走, 不用跳出来再走
打个比方也就是说 111 这样是三步
1101是4步, 看两封邮件, 跳出来 再看最后一封
问最少点击操作数
我for循环ifelse 有6个没过 也不知道为啥 感觉是贪心还是dp这个题没找到出处
(这个不知道在说什么。。)I have a list of qualified engineers (which is also a list) for each feature,然后sort 这个list of lists by length of the list,because the first feature‘s list of qualified engineers is the shortest,so I give the engineer to this feature, when I come to the point when there is no qualifed engineer, I know it’s invalid. 需要share screen
第一题,
已知一个array包含 0 和 1,求它的weight
定义:
Weight of string = Weight of total pairs + weight of single characters - Total number of toggles.
Two consecutive characters are considered as pair only if they are different.
Weight of a single pair (both character are different) = 4Weight of a single character = 1
举例:
input = ‘00’
weight = one pair - one toggle = 4-1=3
input = ‘011’ (可以转变任意数量的0->1 或者 1->0 使之最大化)
weight = one pair + one character = 4 + 1 = 5
读到这里觉得很屌,感觉是挺难的,结果目标函数的输入里面包括了 pair分数,toggle 分数 和 转变分数,一个公式就解决了。
类似例题参考 (https://www.geeksforgeeks.org/maximum-weight-transformation-of-a-given-string/)
第二题,
给一个array of non negative integers, 每一个位置代表青蛙从这个位置能跳跃的最大距离
求青蛙从最左边跳到最右边要最少几步?
举例:
[1, 2, 1, 3, 0, 4, 1, 2, 1]
index 0, 1, 2, 3, 4, 5, 6, 7, 8
青蛙 跳跃位置index : 0, 1, 3, 5, 8 , 四步
相似例题参考链接:
[https://www.geeksforgeeks.org/minimum-number-of-jumps-to-reach-end-of-a-given-array/
给你两个正整数N和M,现在有两种操作:1. 乘2(*2), 2. 减1(-1)。问你最少需要几步才能从N变到M。我用了bfs过的
给你一个只含有0和1的数组,要求你计算出一共有多少种分割方法,使分割完的每个部分只有一个1。这题不难,主要是要考虑全是0的情况,通过全部test case;
LC 原题或者变种:
457 Circular Array Loop(变种)
环的判断标准是:从A出发能够回到A,并且经过的点的数量 < N(N是总共点数)。要求输出环的个数,并且把每个环都打印出来,打印的顺序按起点从小到大。,
402 Remove K Digits
207 Course Schedule