Redtongue

人生苦短,我用Python


  • 首页

  • 归档

  • 分类

  • 标签

  • 关于

  • 搜索

883.Projection Area of 3D Shapes

发表于 2018-08-06 | 更新于: 2018-10-14 | 分类于 leetcode

Description

On a N N grid, we place some 1 1 * 1 cubes that are axis-aligned with the x, y, and z axes.

Each value v = grid[i][j] represents a tower of v cubes placed on top of grid cell (i, j).

Now we view the projection of these cubes onto the xy, yz, and zx planes.

A projection is like a shadow, that maps our 3 dimensional figure to a 2 dimensional plane.

Here, we are viewing the “shadow” when looking at the cubes from the top, the front, and the side.

Return the total area of all three projections.

题目链接:https://leetcode.com/problems/projection-area-of-3d-shapes/description/

Difficulty: easy

阅读全文 »

882.Reachable Nodes In Subdivided Graph

发表于 2018-08-06 | 更新于: 2018-10-14 | 分类于 leetcode

Description

Starting with an undirected graph (the “original graph”) with nodes from 0 to N-1, subdivisions are made to some of the edges.

The graph is given as follows: edges[k] is a list of integer pairs (i, j, n) such that (i, j) is an edge of the original graph,

and n is the total number of new nodes on that edge.

Then, the edge (i, j) is deleted from the original graph, n new nodes (x_1, x_2, …, x_n) are added to the original graph,

and n+1 new edges (i, x_1), (x_1, x_2), (x_2, x_3), …, (x_{n-1}, x_n), (x_n, j) are added to the original graph.

Now, you start at node 0 from the original graph, and in each move, you travel along one edge.

Return how many nodes you can reach in at most M moves.

题目链接:https://leetcode.com/problems/reachable-nodes-in-subdivided-graph/description/

Difficulty: hard

阅读全文 »

881.Boats to Save People

发表于 2018-08-06 | 更新于: 2018-10-14 | 分类于 leetcode

Description

The i-th person has weight people[i], and each boat can carry a maximum weight of limit.

Each boat carries at most 2 people at the same time, provided the sum of the weight of those people is at most limit.

Return the minimum number of boats to carry every given person. (It is guaranteed each person can be carried by a boat.)

题目链接:https://leetcode.com/problems/boats-to-save-people/description/

Difficulty: medium

阅读全文 »

880.Decoded String at Index

发表于 2018-08-06 | 更新于: 2018-10-14 | 分类于 leetcode

Description

An encoded string S is given. To find and write the decoded string to a tape, the encoded string is read one character at a time and the following steps are taken:

  • If the character read is a letter, that letter is written onto the tape.
  • If the character read is a digit (say d), the entire current tape is
    repeatedly written d-1 more times in total.

Now for some encoded string S, and an index K, find and return the K-th letter (1 indexed) in the decoded string.

题目链接:https://leetcode.com/problems/decoded-string-at-index/description/

Difficulty: medium

阅读全文 »

[nowcoder]孩子们的游戏(圆圈中最后剩下的数)

发表于 2018-08-04 | 更新于: 2018-10-15 | 分类于 nowcoder

题目描述

每年六一儿童节,牛客都会准备一些小礼物去看望孤儿院的小朋友,今年亦是如此。HF作为牛客的资深元老,自然也准备了一些小游戏。其中,有个游戏是这样的:首先,让小朋友们围成一个大圈。然后,他随机指定一个数m,让编号为0的小朋友开始报数。每次喊到m-1的那个小朋友要出列唱首歌,然后可以在礼品箱中任意的挑选礼物,并且不再回到圈中,从他的下一个小朋友开始,继续0…m-1报数….这样下去….直到剩下最后一个小朋友,可以不用表演,并且拿到牛客名贵的“名侦探柯南”典藏版(名额有限哦!!^_^)。请你试着想下,哪个小朋友会得到这份礼品呢?(注:小朋友的编号是从0到n-1)

题目链接: https://www.nowcoder.com/practice/f78a359491e64a50bce2d89cff857eb6

阅读全文 »

[nowcoder]扑克牌顺子

发表于 2018-08-04 | 更新于: 2018-10-15 | 分类于 nowcoder

题目描述

LL今天心情特别好,因为他去买了一副扑克牌,发现里面居然有2个大王,2个小王(一副牌原本是54张^_^)…他随机从中抽出了5张牌,想测测自己的手气,看看能不能抽到顺子,如果抽到的话,他决定去买体育彩票,嘿嘿!!“红心A,黑桃3,小王,大王,方片5”,“Oh My God!”不是顺子…..LL不高兴了,他想了想,决定大\小 王可以看成任何数字,并且A看作1,J为11,Q为12,K为13。上面的5张牌就可以变成“1,2,3,4,5”(大小王分别看作2和4),“So Lucky!”。LL决定去买体育彩票啦。 现在,要求你使用这幅牌模拟上面的过程,然后告诉我们LL的运气如何, 如果牌能组成顺子就输出true,否则就输出false。为了方便起见,你可以认为大小王是0。

题目链接: https://www.nowcoder.com/practice/762836f4d43d43ca9deb273b3de8e1f4

阅读全文 »

[nowcoder]翻转单词顺序列

发表于 2018-08-04 | 更新于: 2018-10-15 | 分类于 nowcoder

题目描述

牛客最近来了一个新员工Fish,每天早晨总是会拿着一本英文杂志,写些句子在本子上。同事Cat对Fish写的内容颇感兴趣,有一天他向Fish借来翻看,但却读不懂它的意思。例如,“student. a am I”。后来才意识到,这家伙原来把句子单词的顺序翻转了,正确的句子应该是“I am a student.”。Cat对一一的翻转这些单词顺序可不在行,你能帮助他么?

题目链接: https://www.nowcoder.com/practice/3194a4f4cf814f63919d0790578d51f3

阅读全文 »

[nowcoder]左旋转字符串

发表于 2018-08-04 | 更新于: 2018-10-15 | 分类于 nowcoder

题目描述

汇编语言中有一种移位指令叫做循环左移(ROL),现在有个简单的任务,就是用字符串模拟这个指令的运算结果。对于一个给定的字符序列S,请你把其循环左移K位后的序列输出。例如,字符序列S=”abcXYZdef”,要求输出循环左移3位后的结果,即“XYZdefabc”。是不是很简单?OK,搞定它!

题目链接: https://www.nowcoder.com/practice/12d959b108cb42b1ab72cef4d36af5ec

阅读全文 »

[nowcoder]和为S的两个数字

发表于 2018-08-04 | 更新于: 2018-10-15 | 分类于 nowcoder

题目描述

输入一个递增排序的数组和一个数字S,在数组中查找两个数,使得他们的和正好是S,如果有多对数字的和等于S,输出两个数的乘积最小的。

题目链接: https://www.nowcoder.com/practice/390da4f7a00f44bea7c2f3d19491311b

阅读全文 »

[nowcoder]和为S的连续正数序列

发表于 2018-08-04 | 更新于: 2018-10-15 | 分类于 nowcoder

题目描述

小明很喜欢数学,有一天他在做数学作业时,要求计算出9~16的和,他马上就写出了正确答案是100。但是他并不满足于此,他在想究竟有多少种连续的正数序列的和为100(至少包括两个数)。没多久,他就得到另一组连续正数和为100的序列:18,19,20,21,22。现在把问题交给你,你能不能也很快的找出所有和为S的连续正数序列? Good Luck!

题目链接: https://www.nowcoder.com/practice/c451a3fd84b64cb19485dad758a55ebe

阅读全文 »
1…141516…21
yunxiang wang

yunxiang wang

记录点点

202 日志
4 分类
41 标签
GitHub E-Mail
© 2016 — 2020 yunxiang wang