Given a binary tree rooted at root, the depth of each node is the shortest distance to the root. A node is deepest if it has the largest depth possibl ...
分类:
其他好文 时间:
2018-07-10 17:52:45
阅读次数:
176
Given an array A, we may rotate it by a non-negative integer K so that the array becomes A[K], A[K+1], A{K+2], ... A[A.length - 1], A[0], A[1], ..., A ...
分类:
其他好文 时间:
2018-07-06 13:10:10
阅读次数:
253
题目大意:给你\(A\)个a,\(B\)个b,\(C\)个c,要你构造一个字符串,使它的最小循环表示法最大。求这个表示法。解题思路:不知道怎么证,但把a、b、c当做单独的字符串扔进容器,每次把字典序最小的和字典序最大的两个字符串合并就是答案。容器用multiset即可。 C++ Code: ...
分类:
其他好文 时间:
2018-07-05 19:58:00
阅读次数:
201
You are given two integer arrays nums1 and nums2 sorted in ascending order and an integer k. Define a pair (u,v) which consists of one element from th ...
分类:
其他好文 时间:
2018-07-03 14:54:45
阅读次数:
247
Given N integers, you are supposed to find the smallest positive integer that is NOT in the given list. Input Specification: Each input file contains ...
分类:
其他好文 时间:
2018-06-14 20:57:53
阅读次数:
170
question: Modify binary search so that it always returns the element with the smallest index that mathes the search element (and still guarantees loga ...
分类:
其他好文 时间:
2018-06-03 14:31:23
阅读次数:
132
问题描述: Given an unsorted integer array, find the smallest missing positive integer. Example 1: Example 2: Example 3: Note: Your algorithm should run in ...
分类:
其他好文 时间:
2018-06-02 12:58:11
阅读次数:
165
爆搜解法: 一开始老是超时,用的手动搜索全排列,结果看一下题解,结果全部用的是next_permutation这个函数,就是用来做全排列的,改了一下,竟然过了,不得不说库函数还是蛮强的,推测一下它应该用的应该不是深搜实现的,不然应该不会这么快。(好想知道它用的什么算法呀!) 这个函数在algorit ...
分类:
其他好文 时间:
2018-05-28 21:18:49
阅读次数:
157
1038 Recover the Smallest Number (30)(30 分) Given a collection of number segments, you are supposed to recover the smallest number from them. For exam ...
分类:
其他好文 时间:
2018-05-27 16:47:48
阅读次数:
167
题目链接: https://www.luogu.org/problemnew/show/UVA11536 题目大意: 给定一个$N,M,K$,构造这样的数列: $x[1]=1,x[2]=2,x[3]=3$ $x[i]=(x[i 1]+x[i 2]+x[i 3])\mod M+1(N =i =4)$ ...
分类:
其他好文 时间:
2018-05-26 23:26:46
阅读次数:
395