微软2014年技术岗位在线笔试题

Description
For this question, your program is required to process an input string containing only ASCII characters between ‘0’ and ‘9’, or between ‘a’ and ‘z’ (including ‘0’, ‘9’, ‘a’, ‘z’).

Your program should reorder and split all input string characters into multiple segments, and output all segments as one concatenated string. The following requirements should also be met,
1. Characters in each segment should be in strictly increasing order. For ordering, ‘9’ is larger than ‘0’, ‘a’ is larger than ‘9’, and ‘z’ is larger than ‘a’ (basically following ASCII character order).
2. Characters in the second segment must be the same as or a subset of the first segment; and every following segment must be the same as or a subset of its previous segment.

Your program should output string “<invalid input string>” when the input contains any invalid characters (i.e., outside the ’0′-’9′ and ‘a’-’z’ range).

Input

Input consists of multiple cases, one case per line. Each case is one string consisting of ASCII characters.

Output

For each case, print exactly one line with the reordered string based on the criteria above.

样例输入
aabbccdd
007799aabbccddeeff113355zz
1234.89898
abcdefabcdefabcdefaaaaaaaaaaaaaabbbbbbbddddddee
样例输出
abcdabcd
013579abcdefz013579abcdefz
<invalid input string>
abcdefabcdefabcdefabdeabdeabdabdabdabdabaaaaaaa

Description
Consider a string set that each of them consists of {0, 1} only. All strings in the set have the same number of 0s and 1s. Write a program to find and output the K-th string according to the dictionary order. If such a string doesn’t exist, or the input is not valid, please output “Impossible”. For example, if we have two ‘0’s and two ‘1’s, we will have a set with 6 different strings, {0011, 0101, 0110, 1001, 1010, 1100}, and the 4th string is 1001.

Input
The first line of the input file contains a single integer t (1 ≤ t ≤ 10000), the number of test cases, followed by the input data for each test case.
Each test case is 3 integers separated by blank space: N, M(2 <= N + M <= 33 and N , M >= 0), K(1 <= K <= 1000000000). N stands for the number of ‘0’s, M stands for the number of ‘1’s, and K stands for the K-th of string in the set that needs to be printed as output.

Output
For each case, print exactly one line. If the string exists, please print it, otherwise print “Impossible”.

样例输入
3
2 2 2
2 2 7
4 7 47
样例输出
0101
Impossible
01010111011

Description
Find a pair in an integer array that swapping them would maximally decrease the inversion count of the array. If such a pair exists, return the new inversion count; otherwise returns the original inversion count.

Definition of Inversion: Let (A[0], A[1] … A[n]) be a sequence of n numbers. If i < j and A[i] > A[j], then the pair (i, j) is called inversion of A.

Example:
Count(Inversion({3, 1, 2})) = Count({3, 1}, {3, 2}) = 2
InversionCountOfSwap({3, 1, 2})=>
{
InversionCount({1, 3, 2}) = 1 <– swapping 1 with 3, decreases inversion count by 1
InversionCount({2, 1, 3}) = 1 <– swapping 2 with 3, decreases inversion count by 1
InversionCount({3, 2, 1}) = 3 <– swapping 1 with 2 , increases inversion count by 1
}

Input
Input consists of multiple cases, one case per line.Each case consists of a sequence of integers separated by comma.

Output
For each case, print exactly one line with the new inversion count or the original inversion count if it cannot be reduced.

样例输入
3,1,2
1,2,3,4,5
样例输出
1
0

Description
In a running system, there are many logs produced within a short period of time, we’d like to know the count of the most frequent logs.

Logs are produced by a few non-empty format strings, the number of logs is N(1=N=20000), the maximum length of each log is 256.

Here we consider a log same with another when their edit distance (see note) is = 5.

Also we have a) logs are all the same with each other produced by a certain format string b) format strings have edit distance 5 of each other.

Your program will be dealing with lots of logs, so please try to keep the time cost close to O(nl), where n is the number of logs, and l is the average log length.

Note edit distance is the minimum number of operations (insertdeletereplace a character) required to transform one string into the other, please refer to

http://en.wikipedia.org/wiki/Edit_distance for more details.

Input
Multiple lines of non-empty strings.

Output

The count of the most frequent logs.

样例输入
Logging started for id:1
Module ABC has completed its job
Module XYZ has completed its job
Logging started for id:10
Module ? has completed its job

时间: 2024-09-29 08:25:17

微软2014年技术岗位在线笔试题的相关文章

2015网易校招Java开发工程师(技术架构)在线笔试题

1.  程序和进程的本质区别是? A.在外存和内存存储 B.非顺序和顺序执行机器指令 C.独占使用和分时使用计算机资源 D.静态和动态特征 参考答案分析: 进程与应用程序的区别: 进程(Process)是最初定义在Unix等多用户.多任务操作系统环境下用于表示应用程序在内存环境中基本执行单元的概念.以Unix操作系统 为例,进程是Unix操作系统环境中的基本成分.是系统资源分配的基本单位.Unix操作系统中完成的几乎所有用户管理和资源分配等工作都是通过操作系统 对应用程序进程的控制来实现的. 

2015年网易校招Java开发工程师(技术架构)在线笔试题

1.  程序和进程的本质区别是? A.在外存和内存存储 B.非顺序和顺序执行机器指令 C.独占使用和分时使用计算机资源 D.静态和动态特征 参考答案分析: 进程与应用程序的区别: 进程(Process)是最初定义在Unix等多用户.多任务操作系统环境下用于表示应用程序在内存环境中基本执行单元的概念.以Unix操作系统为例,进程是Unix操作系统环境中的基本成分.是系统资源分配的基本单位.Unix操作系统中完成的几乎所有用户管理和资源分配等工作都是通过操作系统对应用程序进程的控制来实现的.   

2014年网易互联网在线笔试题一道

题目:有四个文件,每个文件中存有100万个int型整数,内存限制1M,该如何最优地得到四个文件的交集数,也就是在四个文件都出现的数的个数? 我的想法:因为内存限制1M,也就是1024*1024个字节,小于一个文件中所有数所占的存储100 0000*4,所以文件中的数没办法一次装到内存.采用外部排序.归并等方法实现. 具体: 1.最开始应该是对每个大文件进行外部排序,也就是n次从大文件中取出一部分数在内存中进行快速排序或堆排序,然后将结果存入小文件中,存入小文件的同时去重: 2.然后对n个小文件进

2014阿里巴巴WEB前端实习生在线笔试题

2014年3月31日晚,我怀着略微忐忑的心情(第一次在线笔试^_^!!)进行了笔试,阿里巴巴的笔试题共有10道,几乎包含了Web前端开发的各个方面,有程序题.有叙述题,时间非常紧张,只完成了大概6道题.下面把遇到的题目跟大家分享一下! 1. <pre name="code" class="html"><!doctype html> <html> <head> <style type="text/css&

2015微软实习在线笔试题 - Professor Q&#39;s Software

时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Professor Q develops a new software. The software consists of N modules which are numbered from 1 to N. The i-th module will be started up by signal Si. If signal Si is generated multiple times, the i-th module

2014年阿里巴巴在线笔试题-第3大题-公共最长字符串长度

说明 2014年阿里巴巴在线笔试题-第3大题    首先,我没参加这次的阿里巴巴在线笔试题,题目全部是从别人口中描述而来,对于以下的分析,如果有什么不对的地方还望指教.也希望大家能够有更好的办法,希望大家来能不吝赐教. 题目描述 给定一个主字符串和一个匹配字符串,现在问你,找出 "主串中可匹配到的匹配串中子串的最大长度",可能比较绕,举个例子吧 主字符串       abcdefgsdff     记为A 匹配字符串   abefgf               记为B 要求的值就是 

google 2014在线笔试题

1.个人做google在线笔试题感觉时间很紧,笔试时间只做出来了一个题目就是第二道题,这第一道题是当天晚上才做出来的...突然感觉自己很水... 个人解决方案需要解决如下子问题 1)判断一个具有坏灯管的数字灯是否显示的是某个数字 2)判断一串灯管显示的是否是以某个数字为首递减的一串数字 3)检查一串匹配正确数字的灯管中坏掉的灯管是哪些 4)输出显示一串正确递减数字的灯管 4)输出显示一串有坏灯管的来显示数字的灯管 #include<iostream> #include <map>

2015年阿里巴巴校招研发工程师在线笔试题汇总

在线笔试题汇总 卷一: 1.下面的函数中哪个是系统调用而不是库函数______? printf scanf fgetc read print_s scan_s 2.某足球队有四名外援,分别来自巴西.荷兰.意大利和美国.他们分别擅长前锋.后卫或守门,其中: ① 美国外援单独擅长守门: ② 意大利外援不擅长前锋: ③ 巴西外援和另外某个外援擅长相同的位置: ④ 荷兰外援擅长的位置和巴西外援不同. 以上条件可以推出巴西外援擅长的位置是______. 前锋 守门 后卫 前锋或守门 后卫或守门 前锋或后卫

48行代码解一道亚马逊的在线笔试题

这题是我从这里看到的一道亚马逊的在线笔试题,具体规则请前往该文章查看,下面贴出我的解题代码: 其中11,12,13,14分别代表J,Q,K,A; class CardCompare { private int[] cards = new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }; public bool CompareCards(int[] cards1, int[] cards2) { return cardsScore(card