chenf99 blog


  • 首页

  • 关于

  • 归档

  • 搜索

leetcode-279

发表于 2018-10-21 | 更新于: 2018-10-21 | 分类于 leetcode
字数统计: 739 字

题目

Perfect Squares

Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n.

Example1

1
2
3
Input: n = 12
Output: 3
Explanation: 12 = 4 + 4 + 4.
阅读全文 »

leetcode-135

发表于 2018-10-10 | 更新于: 2018-10-10 | 分类于 leetcode
字数统计: 771 字

题目

Candy

There are N children standing in a line. Each child is assigned a rating value.

You are giving candies to these children subjected to the following requirements:

  • Each child must have at least one candy.
  • Children with a higher rating get more candies than their neighbors.

What is the minimum candies you must give?

阅读全文 »

leetcode-025

发表于 2018-10-05 | 更新于: 2018-10-05 | 分类于 leetcode
字数统计: 1k 字

题目

Reverse Nodes in k-Group

Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.

k is a positive integer and is less than or equal to the length of the linked list. If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is.

Example

Given this linked list: 1->2->3->4->5

For k = 2, you should return: 2->1->4->3->5

For k = 3, you should return: 3->2->1->4->5

Note:

  • Only constant extra memory is allowed.
  • You may not alter the values in the list’s nodes, only nodes itself may be changed.
阅读全文 »
1…678…10
Chenf99

Chenf99

30 日志
6 分类
10 标签
© 2019 Chenf99
总访客数: 总访问量:
本站共计64.3k字