- 博客(17)
- 收藏
- 关注
原创 LeetCode 416. Partition Equal Subset Sum
Given a non-empty array containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both subsets is equal.Note:Each of the array element w...
2018-05-20 22:38:08 112
原创 LeetCode 198. House Robber
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent house...
2018-05-20 16:13:56 120
原创 LeetCode 279. 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.For example, given n = 12, return 3 because 12 = 4 + 4 + 4; given n = 13, ret...
2018-05-10 19:46:43 117
原创 LeetCode 438. Find All Anagrams in a String
Given a string s and a non-empty string p, find all the start indices of p's anagrams in s.Strings consists of lowercase English letters only and the length of both strings s and p will not be larger ...
2018-05-02 16:38:30 159
原创 LeetCode 3. Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring without repeating characters.Examples:Given "abcabcbb", the answer is "abc", which the length is 3.Given "bbbbb", the answer is "b", with the l...
2018-05-02 15:12:31 104
原创 LeetCode 209. Minimum Size Subarray Sum
Given an array of n positive integers and a positive integer s, find the minimal length of a contiguous subarray of which the sum ≥ s. If there isn't one, return 0 instead.Example: Input: [2,3,1,2,4,3...
2018-05-02 14:55:05 114
原创 LeetCode 11. Container With Most Water
Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two ...
2018-05-01 22:53:19 111
原创 LeetCode 125. Valid Palindrome
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.Note: For the purpose of this problem, we define empty string as valid palindrome.Example 1...
2018-05-01 21:20:11 131
原创 LeetCode 167. Two Sum II - Input array is sorted
Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers su...
2018-05-01 20:37:54 91
原创 LeetCode 215. Kth Largest Element in an Array
Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.For example,Given [3,2,1,5,6,4] and k = 2, return 5.Note: Y...
2018-05-01 17:21:26 115
原创 LeetCode 88. Merge Sorted Array
Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:The number of elements initialized in nums1 and nums2 are m and n respectively.You may assume that nums...
2018-05-01 11:28:48 110
原创 LeetCode 75. Sort Colors
Given an array with n objects colored red, white or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use the inte...
2018-05-01 10:09:55 107
转载 筛法求素数
筛到第 n 个素数,数组需要开多大?素数分布定理: 不大于 n 的素数的个数为: n/ln(n) double t = 100; while(t/log(t) < n) t *= 1.1; cout<<t<<endl;题目:第1个素数是2,第2个素数是3,……求第100002(十万零二)个素数。#include <iostream>...
2018-03-31 10:59:50 144
转载 尼姆堆
有3堆硬币,分别是3,4,5二人轮流取硬币。每人每次只能从某一堆上取任意数量。不能弃权。取到最后一枚硬币的为赢家。求先取硬币一方有无必胜的招法。#include <bits/stdc++.h>using namespace std;// 尼姆堆的摸2加(异或)解法// 10// 101// 1100// 1110 //--------// 0101void f(int a[],i...
2018-03-31 10:15:07 378
转载 高僧斗法
问题描述 古时丧葬活动中经常请高僧做法事。仪式结束后,有时会有“高僧斗法”的趣味节目,以舒缓压抑的气氛。 节目大略步骤为:先用粮食(一般是稻米)在地上“画”出若干级台阶(表示N级浮屠)。又有若干小和尚随机地“站”在某个台阶上。最高一级台阶必须站人,其它任意。(如图1所示) 两位参加游戏的法师分别指挥某个小和尚向上走任意多级的台阶,但会被站在高级台阶上的小和尚阻挡,不能越过。两个小和尚也不能站...
2018-03-31 09:31:55 173
原创 金额查错
某财务部门结账时发现总金额不对头。很可能是从明细上漏掉了某1笔或几笔。如果已知明细账目清单,能通过编程找到漏掉的是哪1笔或几笔吗?如果有多种可能,则输出所有可能的情况。我们规定:用户输入的第一行是:有错的总金额。接下来是一个整数n,表示下面将要输入的明细账目的条数。再接下来是n行整数,分别表示每笔账目的金额。要求程序输出:所有可能漏掉的金额组合。每个情况1行。金额按照从小到大排列,中间用空格分开。...
2018-03-31 09:18:48 348
原创 2018 蓝桥杯省赛 B 组模拟赛(一)-U型数字
最近蒜头君喜欢上了U型数字,所谓U型数字,就是这个数字的每一位先严格单调递减,后严格单调递增。比如 212212 就是一个U型数字,但是 333333, 9898, 567567, 3131331313,就是不是U型数字。现在蒜头君问你,[1,100000][1,100000] 有多少U型数字?提示:请不要输出多余的符号。#include <bits/stdc++.h>using na...
2018-03-30 22:14:56 203
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人