Nutanix OA合集

砍出一个美丽的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的em‍‍‍‍‍‍‍‍‌‌‌‌‌‍‍‍‌‌‍ail
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 eng‍‍‍‍‍‍‍‍‌‌‌‌‌‍‍‍‌‌‍ineers 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


第一道题:
pizza 有两种discount:
(1) 2 pizzas /1 day
(2) 1 pizza 连续两天
test case :
4
1 2 1 2
yes
四天, 第一天买一个, 第二天买两个,第三天一个,第四天买两个
有使用优惠的解
3
1 0 1
no
无法使用优惠。

test case:
4
1 1 1 1
output:4 , 4 个1
21
10 11
output:2
所有的合法的数字 只能含有 0 或 1,
11 ,101,111 类似是合法的。
20, 22 是不合法的。
使用合法的数去组成数组, 最少的组成个数。

他家做OA需要share screen,可以只share 浏览器
今天考了 beautiful row
另外一题是问有几种方式分割 1
input是只有0和1的int array,每个continuous section要有一个1,任意个0

input: 01
output: 1

input: 10101
这样切割:
1 | 01 | 01
1 | 010 | 1
10 | 1 | 01
10 | 10 | 1
output: 4

还在考这道

A farmer has n trees in a row in his garden. He thinks, that a row of trees is beautiful if heights of trees in it are first increasing, then decreasing. For example, 2 5 6 3 is a beautiful row whereas 1 3 4 2 5 is not a beautiful row. The row of trees in farmers garden may not be beautiful. Help the farmer, cut down the minimum number of trees to make the row beautiful.
A row, sorted in increasing order and without any decreasing part is considered beautiful.
A row, sorted in decreasing order and without any increasing part is considered beautiful.

Input
The first line of input contains integer n.
The second line of input contains n space-separated integers - k1, k2, k3 ,…,kn.

Output
Print the value, representing the minimum number of trees you need to cut down to make a row beautiful.

Constraints
1 <= n <= 1000.
1 <= ki < 1000000.

Example#1
Input
8
3 17 4 12 5 6 2 1
Output
2
We can cut down 17 and 5.

Example#2
Input
4
1 2 100 99
Output
0
This row is already beautiful.