08 2016 档案

摘要:Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the 阅读全文
posted @ 2016-08-31 23:04 琴影 阅读(349) 评论(0) 推荐(0) 编辑
摘要:Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the rans 阅读全文
posted @ 2016-08-31 22:37 琴影 阅读(245) 评论(0) 推荐(0) 编辑
摘要:Given two strings s and t which consist of only lowercase letters. String t is generated by random shuffling string s and then add one more letter at 阅读全文
posted @ 2016-08-31 22:18 琴影 阅读(1309) 评论(0) 推荐(1) 编辑
摘要:Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. For example: Given num = 38, the process is like: 阅读全文
posted @ 2016-08-31 21:48 琴影 阅读(192) 评论(0) 推荐(0) 编辑
摘要:编制程序,输入n个整数(n从键盘输入,n>0),输出它们的偶数和。 输入:第一行n,代表n个整数 ,第二行以空格间隔,输入n个整数. 输出:为偶数的所有整数的和。 编制程序,输入n个整数(n从键盘输入,n>0),输出它们的偶数和。 输入:第一行n,代表n个整数 ,第二行以空格间隔,输入n个整数. 输 阅读全文
posted @ 2016-08-30 23:33 琴影 阅读(375) 评论(0) 推荐(0) 编辑
摘要:下面我将描述一个简单的函数: f(8)=2 f(16)=1 f(32)=0 f(2048)=3 读入一个x(1≤x≤101000),请你找出f(x)的值。 输入包括一行,仅一个数字x。 输出包括一行,仅一个数字f(x)。 提示: f(0)=1, f(1)=0, f(2)=0, f(3)=0, f(4 阅读全文
posted @ 2016-08-30 23:27 琴影 阅读(218) 评论(0) 推荐(0) 编辑
摘要:Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maxim 阅读全文
posted @ 2016-08-28 22:43 琴影 阅读(147) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree, return all root-to-leaf paths. For example, given the following binary tree: All root-to-leaf paths are: 阅读全文
posted @ 2016-08-28 17:10 琴影 阅读(737) 评论(0) 推荐(0) 编辑
摘要:Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1. Examples: Note: You may assume the 阅读全文
posted @ 2016-08-27 13:14 琴影 阅读(1791) 评论(0) 推荐(1) 编辑
摘要:给定一个数组,找到两个数,使得他们的和为一个给定的数值target。 函数twoSum返回两个数字index1,index2, 其中:number[index1] + number[index2]==target; 注意:index1必须小于index2且不能为0假设每一组输入只有唯一的一组解。 格 阅读全文
posted @ 2016-08-26 01:09 琴影 阅读(259) 评论(0) 推荐(0) 编辑
摘要:时间限制:1000ms 单点时限:1000ms 内存限制:256MB 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 fjxmlhx每天都在被沼跃鱼刷屏,因此他急切的找到了你希望你写一个程序屏蔽所有句子中的沼跃鱼(“marshtomp”,不区分大小写)。为了使句子不缺少成 阅读全文
posted @ 2016-08-26 00:26 琴影 阅读(621) 评论(0) 推荐(0) 编辑
摘要:Fence Repair Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 40465 Accepted: 13229 Description Farmer John wants to repair a small length o 阅读全文
posted @ 2016-08-23 23:10 琴影 阅读(292) 评论(0) 推荐(0) 编辑
摘要:[1]POJ 动态规划题目列表 容易: 1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, 1189, 1208, 1276, 1322, 1414, 1456, 1458, 1609, 1644, 1664, 1690, 1699 阅读全文
posted @ 2016-08-23 21:37 琴影 阅读(415) 评论(0) 推荐(0) 编辑
摘要:Saruman's Army Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7853 Accepted: 4012 Description Saruman the White must lead his army along a 阅读全文
posted @ 2016-08-23 21:18 琴影 阅读(161) 评论(0) 推荐(0) 编辑
摘要:Best Cow Line Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 19186 Accepted: 5319 Description FJ is about to take his N (1 ≤ N ≤ 2,000) co 阅读全文
posted @ 2016-08-23 20:57 琴影 阅读(259) 评论(0) 推荐(0) 编辑
摘要:迷宫问题 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 16238 Accepted: 9692 Description 定义一个二维数组: int maze[5][5] = { 0, 1, 0, 0, 0, 0, 1, 0, 阅读全文
posted @ 2016-08-22 23:53 琴影 阅读(176) 评论(0) 推荐(0) 编辑
摘要:字符串替换 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 10871 Accepted: 5100 Description 编写一个C程序实现将字符串中的所有"you"替换成"we" Input 输入包含多行数据 每行数据是一个 阅读全文
posted @ 2016-08-22 21:01 琴影 阅读(239) 评论(0) 推荐(0) 编辑
摘要:取模运算 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 10931 Accepted: 6618 Description 编写一个C函数mod(int n, int m),实现取模运算% Input 输入包含多行数据 每行数据是 阅读全文
posted @ 2016-08-22 20:40 琴影 阅读(287) 评论(0) 推荐(0) 编辑
摘要:分数加减法 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 13666 Accepted: 4594 Description 编写一个C程序,实现两个分数的加减法 Input 输入包含多行数据 每行数据是一个字符串,格式是"a/b 阅读全文
posted @ 2016-08-22 19:47 琴影 阅读(329) 评论(0) 推荐(0) 编辑
摘要:每个测试案例包括两行: 第一行包含一个整数n,表示数组中的元素个数。其中1 <= n <= 10^5。 第二行包含n个整数,每个数组均为int类型。 1.直接的做法是逐个统计,复杂度是N^2, 2.可以利用归并排序的思想,在排序过程中统计逆序对的个数。时间复杂度依然是 N*Log(N)。 可以从代码 阅读全文
posted @ 2016-08-21 23:30 琴影 阅读(568) 评论(0) 推荐(0) 编辑
摘要:关于精度问题 在计算几何的计算中,精度问题是一个很常见的问题。 这是由于计算机存储浮点数时保留的精度有限而产生的。 即使用两个实型变量来存储同一个数字,都有可能产生误差。 因此在判定实型变量大小关系时,若直接采用=,>或<进行比较,很有可能出错。 一般常见的解决方法是设定一个极小量epsilon(一 阅读全文
posted @ 2016-08-17 22:20 琴影 阅读(485) 评论(0) 推荐(0) 编辑
摘要:#1237 : Farthest Point #1237 : Farthest Point 时间限制:5000ms 单点时限:1000ms 内存限制:256MB 描述 Given a circle on a two-dimentional plane. Output the integral poi 阅读全文
posted @ 2016-08-17 22:19 琴影 阅读(292) 评论(0) 推荐(0) 编辑
摘要:FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 67291 Accepted Submission(s): 229 阅读全文
posted @ 2016-08-16 23:48 琴影 阅读(244) 评论(0) 推荐(0) 编辑
摘要:Balloon Comes! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 26455 Accepted Submission(s): 1005 阅读全文
posted @ 2016-08-16 20:49 琴影 阅读(269) 评论(0) 推荐(0) 编辑
摘要:题目描述 查找和排序 题目:输入任意(用户,成绩)序列,可以获得成绩从高到低或从低到高的排列,相同成绩 都按先录入排列在前的规则处理。 例示: jack 70 peter 96 Tom 70 smith 67 从高到低 成绩 peter 96 jack 70 Tom 70 smith 67 从低到高 阅读全文
posted @ 2016-08-07 13:01 琴影 阅读(723) 评论(0) 推荐(0) 编辑
摘要:Evaluation of Expression Tree <!-- .entry-header --> Given a simple expression tree, consisting of basic binary operators i.e., + , – ,* and / and som 阅读全文
posted @ 2016-08-07 09:35 琴影 阅读(386) 评论(0) 推荐(0) 编辑
摘要:Next Power of 2 <!-- .entry-header --> Write a function that, for a given no n, finds a number p which is greater than or equal to n and is a power of 阅读全文
posted @ 2016-08-07 09:03 琴影 阅读(481) 评论(0) 推荐(0) 编辑
摘要:1.string类成员函数c_str()的原型: const char *c_str()const;//返回一个以null终止的c字符串 2.c_str()函数返回一个指向正规c字符串的指针,内容和string类的本身对象是一样的,通过string类的c_str()函数能够把string对象转换成c 阅读全文
posted @ 2016-08-06 11:00 琴影 阅读(2675) 评论(0) 推荐(0) 编辑
摘要:#1049 : 后序遍历 <!-- parameter: @time_limit @case_time_limit @memory_limit @description @sample_input @sample_output --> 时间限制:10000ms 单点时限:1000ms 内存限制:25 阅读全文
posted @ 2016-08-06 10:44 琴影 阅读(251) 评论(0) 推荐(0) 编辑
摘要:#1310 : 岛屿 <!-- parameter: @time_limit @case_time_limit @memory_limit @description @sample_input @sample_output --> 时间限制:10000ms 单点时限:1000ms 内存限制:256M 阅读全文
posted @ 2016-08-06 09:04 琴影 阅读(491) 评论(0) 推荐(0) 编辑
摘要:Follow up for "Unique Paths": Now consider if some obstacles are added to the grids. How many unique paths would there be? An obstacle and empty space 阅读全文
posted @ 2016-08-03 16:00 琴影 阅读(182) 评论(0) 推荐(0) 编辑
摘要:A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any p 阅读全文
posted @ 2016-08-03 15:28 琴影 阅读(197) 评论(0) 推荐(0) 编辑
摘要:You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you cl 阅读全文
posted @ 2016-08-03 14:50 琴影 阅读(121) 评论(0) 推荐(0) 编辑
摘要:Journey with Pigs Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3004 Accepted: 922 Description Farmer John has a pig farm near town A. He 阅读全文
posted @ 2016-08-03 11:40 琴影 阅读(235) 评论(0) 推荐(0) 编辑
摘要:Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary representation and r 阅读全文
posted @ 2016-08-02 21:55 琴影 阅读(248) 评论(0) 推荐(0) 编辑
摘要:Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime comple 阅读全文
posted @ 2016-08-02 18:38 琴影 阅读(102) 评论(0) 推荐(0) 编辑
摘要:Given an integer (signed 32 bits), write a function to check whether it is a power of 4. Example: Given num = 16, return true. Given num = 5, return f 阅读全文
posted @ 2016-08-02 18:13 琴影 阅读(242) 评论(0) 推荐(0) 编辑
摘要:You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time 阅读全文
posted @ 2016-08-02 16:52 琴影 阅读(319) 评论(0) 推荐(0) 编辑
摘要:Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), retur 阅读全文
posted @ 2016-08-01 23:48 琴影 阅读(727) 评论(0) 推荐(0) 编辑
摘要:Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight). For example, the 32-bit 阅读全文
posted @ 2016-08-01 23:37 琴影 阅读(172) 评论(0) 推荐(0) 编辑
摘要:Given an integer, write a function to determine if it is a power of two. 题目大意:判断一个数是否是2的指数次。 思路一:如果一个数是2的指数次,那么它对应的二进制数中只有一个1;利用位运算即可解决。‘ 思路二:如果一个整数是2 阅读全文
posted @ 2016-08-01 23:31 琴影 阅读(179) 评论(0) 推荐(0) 编辑