leetcode之Intersection of two arrays,delete node in a list, same tree 思路都比较简单,主要就是要代码简洁和做到bug free1.注意size()==02.注意delete3.注意直接实现 和 代码简洁度
codeforce之Magic Powder 题目:The term of this problem is the same as the previous one, the only exception — increased restrictions.InputThe first line contains two positive integers n and k (1 ≤ n ≤ 100 000
codeforce之Bear and Two Paths 题目:Bearland has n cities, numbered 1 through n. Cities are connected via bidirectional roads. Each road connects two distinct cities. No two roads connect the same pair of cities.Bear Li
codeforce之 Bear and Colors 题目:Bear Limak has n colored balls, arranged in one long row. Balls are numbered 1 through n, from left to right. There are n possible colors, also numbered 1 through n. The i-th ball has c
codeforce之problems for round 题目:There are n problems prepared for the next Codeforces round. They are arranged in ascending order by their difficulty, and no two problems have the same difficulty. Moreover, there are m
CF之Recycling Bottles 题目:It was recycling day in Kekoland. To celebrate it Adil and Bera went to Central Perk where they can take bottles from the ground and put them into a recycling bin.We can think Central P
CF之Vasya and String 题目:High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotesbeauty of the string as the maximum length of a su
code force 之 Money transfer 转化为求最多和为0的子数组,其实就是前缀和的次数#include#include#include#include#include#include#include#include#includeusing namespace std;map m;int a[100001];int max(int a, int b) { return a > b ? a : b;}in
lintcode之不同子序列数 + 序列II 不同子序列:很明显是dp, 当位置相等的时候,等于f(i - 1, j - 1) + f(i, j - 1 )否则就是f(i, j - 1)子序列:找打第一个相邻升序,从后向前找到第一个大于的,交换,排序
编程之美只有加法的面试题 1:枚举个数(个数的大小是有限的,可以进行放缩)num=i + i+1 + i+2 + ....+ i+k-1 一共有k个数。= (i + i+k-1)*k/2=(2*i+k-1)*k/2=k*(i+ (k-1)/2)=k*i + k*(k-1)/2判断条件: num%(k*(k-1)/2)==0 或者 2*num>k*(k-1) 得: ki=num/k;可得出i