Redtongue

人生苦短,我用Python


  • 首页

  • 归档

  • 分类

  • 标签

  • 关于

  • 搜索

879.Profitable Schemes

发表于 2018-07-30 | 更新于: 2018-10-25 | 分类于 leetcode

Description

There are G people in a gang, and a list of various crimes they could commit.

The i-th crime generates a profit[i] and requires group[i] gang members to participate.

If a gang member participates in one crime, that member can’t participate in another crime.

Let’s call a profitable scheme any subset of these crimes that generates at least P profit, and the total number of gang members participating in that subset of crimes is at most G.

How many schemes can be chosen? Since the answer may be very large, return it modulo 10^9 + 7.

题目链接:https://leetcode.com/problems/profitable-schemes/

Difficulty: hard

阅读全文 »

878.Nth Magical Number

发表于 2018-07-30 | 更新于: 2018-10-25 | 分类于 leetcode

Description

A positive integer is magical if it is divisible by either A or B.

Return the N-th magical number. Since the answer may be very large, return it modulo 10^9 + 7.

题目链接:https://leetcode.com/problems/nth-magical-number/

Difficulty: hard

阅读全文 »

877.Stone Game

发表于 2018-07-30 | 更新于: 2018-10-25 | 分类于 leetcode

Description

Alex and Lee play a game with piles of stones. There are an even number of piles arranged in a row, and each pile has a positive integer number of stones piles[i].

The objective of the game is to end with the most stones. The total number of stones is odd, so there are no ties.

Alex and Lee take turns, with Alex starting first. Each turn, a player takes the entire pile of stones from either the beginning or the end of the row. This continues until there are no more piles left, at which point the person with the most stones wins.

Assuming Alex and Lee play optimally, return True if and only if Alex wins the game.

题目链接:https://leetcode.com/problems/stone-game/

Difficulty: medium

阅读全文 »

876.Middle of the Linked List

发表于 2018-07-30 | 更新于: 2018-10-25 | 分类于 leetcode

Description

Given a non-empty, singly linked list with head node head, return a middle node of linked list.

If there are two middle nodes, return the second middle node.

题目链接:https://leetcode.com/problems/middle-of-the-linked-list/

Difficulty: easy

阅读全文 »

[nowcoder]包含min函数的栈

发表于 2018-07-29 | 更新于: 2018-10-15 | 分类于 nowcoder

题目描述

定义栈的数据结构,请在该类型中实现一个能够得到栈中所含最小元素的min函数(时间复杂度应为O(1))。

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

阅读全文 »

[nowcoder]顺时针打印矩阵

发表于 2018-07-29 | 更新于: 2018-10-15 | 分类于 nowcoder

题目描述

输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字,例如,如果输入如下4 X 4矩阵: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 则依次打印出数字1,2,3,4,8,12,16,15,14,13,9,5,6,7,11,10.

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

阅读全文 »

[nowcoder]二叉树的镜像

发表于 2018-07-29 | 更新于: 2018-10-15 | 分类于 nowcoder

题目描述

操作给定的二叉树,将其变换为源二叉树的镜像。

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

阅读全文 »

[nowcoder]树的子结构

发表于 2018-07-29 | 更新于: 2018-10-15 | 分类于 nowcoder

题目描述

输入两棵二叉树A,B,判断B是不是A的子结构。(ps:我们约定空树不是任意一个树的子结构)

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

阅读全文 »

[nowcoder]合并两个排序的链表

发表于 2018-07-29 | 更新于: 2018-10-15 | 分类于 nowcoder

题目描述

输入两个单调递增的链表,输出两个链表合成后的链表,当然我们需要合成后的链表满足单调不减规则。

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

阅读全文 »

[nowcoder]反转链表

发表于 2018-07-29 | 更新于: 2018-10-15 | 分类于 nowcoder

题目描述

输入一个链表,反转链表后,输出新链表的表头。

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

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

yunxiang wang

记录点点

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