*candy——leetcode】的更多相关文章

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 ca…
/* */ #include<iostream> #include<vector> //#include<algorithm> #include <windows.h> using namespace std; #define STOP system("pause"); #if 1 class Solution { public: int candy(vector<int> &ratings) { int len =…
题目: 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 cand…
对于ratings[i+1],和ratings[i]的关系有下面几种: 1. 相等.相等时ratings[i+1]相应的糖果数为1 2.ratings[i + 1] > ratings[i].在这样的情况下,要寻找以ratings[i]開始的递增序列. 3.ratings[i + 1] < ratings[i].在这样的情况下,要寻找以ratings[i]開始的递减序列. 对于随意一个递增序列 [2 3 4 5 6] 相应的糖果数为 [1 2 3 4 X] 对于随意一个递减序列[6 5 4 3…
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…
最近在准备找工作的算法题,刷刷LeetCode,以下是我的解题报告索引,每一题几乎都有详细的说明,供各位码农参考.根据我自己做的进度持续更新中......                              本文地址 LeetCode:Reverse Words in a String LeetCode:Evaluate Reverse Polish Notation LeetCode:Max Points on a Line LeetCode:Sort List LeetCode:Ins…
Here is my collection of solutions to leetcode problems. Related code can be found in this repo: https://github.com/zhuli19901106/leetcode LeetCode - Course Schedule LeetCode - Reverse Linked List LeetCode - Isomorphic Strings LeetCode - Count Primes…
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…
Problem link: http://oj.leetcode.com/problems/candy/ Suppose we are given an array R[1..N] that are ratings of N children. Let C[1..N] be a new array where C[i] is the number of candies for i-th child. From the description, C[i] should meet following…
原文:http://www.cnblogs.com/AndyJee/p/4483043.html 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…