由买买提看人间百态

topics

全部话题 - 话题: ascii
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)
u******g
发帖数: 89
1
char变为负数的implication是原来里面的char都是ASCII的(<127)。。。
s*******n
发帖数: 305
2
来自主题: JobHunting版 - 问一道题(8)

不算吧, 一个是 ' ', 另一个是'', ASCII码没有后面的。
a**********0
发帖数: 422
3
来自主题: JobHunting版 - txt 每行的长度有无最大限制?
就是那个 \n了 哈哈 主要担心hadoop的mapper 我设置的是ascii作为输入
r******l
发帖数: 10760
4
来自主题: JobHunting版 - 这个题有什么好方法吗?
strstr的一个变种。输入是两个string A和B,长度分别是n和k(n>>k)。输出是A里面
的一个长度为k的substr C,要求B和C之间的距离最小。两个等长的string的距离的定
义为每个对应字符之间距离的平方之和。两个字符之间的距离就是ASCII码的差(比如A
和B的距离为1,A和Z的距离为25)。
如果B是A的子串,则C=B,最小距离就是0。这个可以用KMP、BM、RK等很多方法快速解
决。但是如果B不一定是A的子串,除了最直接的双重循环O(nk)的解法,还有没有更好
的解法呢?
z*****5
发帖数: 38
5
来自主题: JobHunting版 - google 电面

如果是ascii码,那只要建一个128个element的数组,再把string遍历一遍,统计每个
字符出现的次数就行了。
如果是unicode,那么建一个几万个element的数组会导致空间吃紧。。。具体咋解决求
高人解惑啊。
如果只有5,6个元素的话就容易了,可以把string sort了找,省下了额外空间。
s********u
发帖数: 1109
6
来自主题: JobHunting版 - Google第二轮电面
各种不顺,早上apple来了拒信,下午google面的也不好,阿森纳还输球。。
可能还是沟通能力太差了,应该是很简单的题目,就是不知道他想说什么。
我发觉面试相比leetcode一大难度就是有时候面试官会说的比较vague,要靠自己问。
。要是他每次都直接把题目书写出来,倒是方便多了。。
就是实现一个strchr,只不过第二个参数不是字符,而是字符串,返回第一次出现的指
针。
/*
Find the first occurrence in str of _any_ character in set. Both are NULL
terminated ASCII C-strings. This is like strchr, except that the second
parameter functions as a set, rather than a single character.
str set returns
qxcdef csz str + 2 == &str[2]
axcdef wya str + 0 == &str[0]
axcdef cxa... 阅读全帖
s********u
发帖数: 1109
7
来自主题: JobHunting版 - Google第二轮电面
这个编码方式至少会告诉你,不会跟ascii混淆。
s********u
发帖数: 1109
8
来自主题: JobHunting版 - Google第二轮电面
各种不顺,早上apple来了拒信,下午google面的也不好,阿森纳还输球。。
可能还是沟通能力太差了,应该是很简单的题目,就是不知道他想说什么。
我发觉面试相比leetcode一大难度就是有时候面试官会说的比较vague,要靠自己问。
。要是他每次都直接把题目书写出来,倒是方便多了。。
就是实现一个strchr,只不过第二个参数不是字符,而是字符串,返回第一次出现的指
针。
/*
Find the first occurrence in str of _any_ character in set. Both are NULL
terminated ASCII C-strings. This is like strchr, except that the second
parameter functions as a set, rather than a single character.
str set returns
qxcdef csz str + 2 == &str[2]
axcdef wya str + 0 == &str[0]
axcdef cxa... 阅读全帖
s********u
发帖数: 1109
9
来自主题: JobHunting版 - Google第二轮电面
这个编码方式至少会告诉你,不会跟ascii混淆。
d**********x
发帖数: 4083
10
来自主题: JobHunting版 - 攒人品!发面经
1. memorization and search branch trimming. try to solve this: http://poj.org/problem?id=3076
2. bit mask for ASCII and hashtable for complex encodings.

subbox
n****e
发帖数: 678
11
来自主题: JobHunting版 - 攒人品!发面经
请问:
第一题sudoku puzzle, 怎么用memorization 进行优化,只会backtracing的方法。
第二题,一直不清楚c/c++ bit mask 用什么STL比较好,ASCII有256个characters。用
Int[]比较费,可是也没有32Byte的data structure.
j*******t
发帖数: 223
12
sedgewick的书里有讲过很简单的trie。
public class TrieST {
private static final int R = 256; // extended ASCII
private Node root = new Node();
private static class Node {
private Object val;
private Node[] next = new Node[R];
}
public boolean contains(String key) {
return get(key) != null;
}
public Value get(String key) {
Node x = get(root, key, 0);
if (x == null) {
return null;
}
return (Value) x.val;
}
... 阅读全帖
j*******t
发帖数: 223
13
sedgewick的书里有讲过很简单的trie。
public class TrieST {
private static final int R = 256; // extended ASCII
private Node root = new Node();
private static class Node {
private Object val;
private Node[] next = new Node[R];
}
public boolean contains(String key) {
return get(key) != null;
}
public Value get(String key) {
Node x = get(root, key, 0);
if (x == null) {
return null;
}
return (Value) x.val;
}
... 阅读全帖
f********4
发帖数: 988
14
来自主题: JobHunting版 - L一个电面题
1。可以啊,这个和什么语言没有关吗。。ASCII的话都这样的吧。。
2。set就是hash—map啊,本来就不用更新啊,汗。出现十次说明9次是重复的啊,没有
问题的

[发表自未名空间手机版 - m.mitbbs.com]
i**********e
发帖数: 1145
15
来自主题: JobHunting版 - 被Leetcode小雷了一把
嗯。这是因为那个0 前面有个 NUL character (ascii code 0),但没显示出来。
我尝试了好几个其他online ide 也没有显示出来。
这种情况你只能用自己的机器跑才能看到了。
e*******s
发帖数: 1067
16
来自主题: JobHunting版 - 如何快速写bug free code
一句话可以顶几十上百行代码
比如简单的string input,直接说特殊字符不考虑,非ascii不考虑,太长不考虑等等,
省下时间空间写核心算法
交流最重要。能说就不要写。再bug free的代码在特定条件下也会出问题,术语叫"bug"
l******g
发帖数: 188
17
get the total number of unique lines across a data set of 1000 gzipped text
files.
for instance: If every file has two lines, "this is line1" and "this a
line2", then the total count of lines is 2000, and total number of unique
lines is 2.
1 1000 machines where each machine has one gzipped text file with an
approximate size of 50GB. The file on each machine is /0/data/foo.txt.gz
2 1000 machines are named data1, data2,..data1000.
3 Data format ASCII text.
4 we have 11 machines named res1, res2…r... 阅读全帖
l******g
发帖数: 188
18
get the total number of unique lines across a data set of 1000 gzipped text
files.
for instance: If every file has two lines, "this is line1" and "this a
line2", then the total count of lines is 2000, and total number of unique
lines is 2.
1. 1000 machines where each machine has one gzipped text file with an
approximate size of 50GB. The file on each machine is /0/data/foo.txt.gz
2. 1000 machines are named data1, data2,..data1000.
3. Data format ASCII text.
4. we have 11 machines named res1, re... 阅读全帖
y*****m
发帖数: 723
19
来自主题: JobHunting版 - xor cipher面试题求解
要求写一个xor cipher的utility。
要求摘要:“Create a utility that will perform a simple XOR cryptographic
transform on a given set of data. The encryption key will be provided by the
binary data in an arbitrarily-sized external file. The size of the key in
bytes will dictate the "block size." The plaintext data will be given on
stdin, where the utility will then break it into block-sized sections, XOR
it against the key, and write the cypher text to stdout. After each block is
processed, the key should be ro... 阅读全帖
r****r
发帖数: 159
20
来自主题: JobHunting版 - 求解一道题 思路也好
ReplacementGrammar
Problem:
You will receive a message that must be translated by several string
replacement rules. However, the exact replacement rules are not fixed - they
will be provided as part of the input. You are to write a program that
receives a list of string replacements rules followed by a message, and
outputs the translated message.
Details:
0) A 'newline' consists of a carriage feed 'r' followed by a line feed 'n'.
1) The input will begin with any number of 'string replacement rul... 阅读全帖
b********t
发帖数: 2
21
来自主题: JobHunting版 - AMAZON onsite 3月面经
第一轮:
印度小哥,先讲project。
实现一个二叉树的类,包含parent节点。
给一个二叉树的任意节点,返回inorder遍历的下一个节点。
刚开始写了返回右子树最左边的节点,后来经提醒补充了没有子树要从parent里找的情
况。中间穿插问了一些java和数据结构的小问题,不难。
第二轮:
白人,kindle组搞测试的,先是自我介绍。
然后写题:给一个string,返回出现频率最高的字符。
先给他讨论思路,问他这些char在不在ASCII范围内,他说good question,不一定。
然后用hashmap写了出来,中间让我解释了一下hash得概念,还有一些小问题记不清了
都不难。
中间遍历hashmap的时候卡了一下,忘了那个KV pair怎么写了,经提醒写出来了,后来
又发现不用遍历hashmap,直接遍历string就可以,然后改正。
最后问了一些测试的问题, 比如刚才是我写的如果输入String为空,就返回null,但
是我的方法返回类型是char,不能用null,后来告诉我可以返回‘\0’(这个我之前还
真不知道。。。)
后来又问我改如何测试,给了几个test case... 阅读全帖
r*******2
发帖数: 104
22

好的,我把我的解题过程也说一下。Leetcode原题就不用说了。
第一组:
第1轮:判断subtree。假设两棵树T1和T2,先用DFS在T1里找到和T2的root一样的结点
,然后从找到的结点开始和T2进行比较,我用了BFS,就是用queue,一边一个queue,
同时push/pop进行比较,如果碰到不一样的就return false。做完了想起来其实就是
Leetcode上的Same Tree,直接还用DFS递归比queue省事。
第2轮:找出maze中的path。开一个matrix标记maze的每一个点是否访问过,然后DFS搜
索,从起点开始,查找它的上下左右邻居,如果没有访问过也没有obstacle,就作为一
个选择进行下一步搜索,一直递归下去直到找到终点为止。
第3轮:设计题。
第4轮:ASCII和Kanji字符的题以前面过,当时没做出来,答案就是回来网上搜的(参
考这个网址http://discuss.joelonsoftware.com/default.asp?interview.11.334807.4)。Spiral Matrix是Leetcode原题就不说了。
第... 阅读全帖
w******g
发帖数: 189
23
来自主题: JobHunting版 - airBnb电面面经
用BFS expand这个算法,如果target word的substitution操作字符范围是256个(ASCII
码表)的话,复杂度好像很大哦。谁能贡献一个这个算法的code并分析一下复杂度吗?
G**C
发帖数: 365
24
来自主题: JobHunting版 - airBnb电面面经
onsite 拿到了吗?

ASCII
w******g
发帖数: 189
25
来自主题: JobHunting版 - airBnb电面面经
用BFS expand这个算法,如果target word的substitution操作字符范围是256个(ASCII
码表)的话,复杂度好像很大哦。谁能贡献一个这个算法的code并分析一下复杂度吗?
G**C
发帖数: 365
26
来自主题: JobHunting版 - airBnb电面面经
onsite 拿到了吗?

ASCII
l*********r
发帖数: 136
27
来自主题: JobHunting版 - G家面经(已被HC挂,求分析)
背景:中部弱校master,去年五月毕业,刚工作一年(中部小公司),骑驴找马中。
Onsite一共五轮:
--------------------------------------
第一轮(中东人):
给一个字符串,让压缩并解压,压缩算法类似leetcode中的count and say
输入:aabbbccd 压缩结果:2a3b2cd(注意,'d'前面没有'1')
引申:输入中如果有数字的话,解压时需要注意歧义问题,例如2a可以解压为'2a'或
者'aa',问如何解决。答曰用类似ascii码中加反斜杠的做法,或者加个header来标
志压缩过的位,表示同意。
第二轮(老印):
(leetcode) edit distance,以DP解之,喜。
(leetcode) word ladder,直接给出BFS,不喜,要优化,想了半天给出的答案皆不
喜,最后提示我可以双向BFS,时间不够,没有给出代码。
-----------------午饭-------------------
第三轮(老白)
给一个int的矩阵arr,让返回一个同样大小的result矩阵,每一个result[i][j]... 阅读全帖
Q*****a
发帖数: 33
28
来自主题: JobHunting版 - Google onsite 题目求助
string LongestMostTwoSubString(string s) {
printf("s.size():%dn", s.size());
// assume char in s are all ASCII, otherwise we can unsigned char and
256 slots
vector charCounts(128, 0);
int maxStart = 0;
int maxLen = 0;
int start = 0, end = 0;
for (;;) {
while (end < s.size() && ++charCounts[s[end]] <= 2) ++end;
int len = end - start;
if (len > maxLen) {
maxStart = start;
maxLen = len;
}
if (end == s.s... 阅读全帖
Q*****a
发帖数: 33
29
来自主题: JobHunting版 - Google onsite 题目求助
这个偶审题错误,原题是要求如同aaaaabbb这样最多不超过两个不一样的字符构成的子
串,我理解成如abcdabcd这种每个字符出现最多不超过两次。代码没有sally216的简洁
,不过个人习惯解这种区间问题的时候这么写了。顺便鄙视一下买买提的发文超时,居
然没有在session里保存,辛苦敲了半天的东西都没了。telnet时代就有的功能居然都
没实现。
string LongestMostTwoCharsSubString(string s) {
// assume char in s are all ASCII, otherwise we can unsigned char and
256 slots
vector charCounts(128, 0);
int maxStart = 0;
int maxLen = 0;
int start = 0, end = 0;
int uniqCharCounts = 0;
for (;;) {
for (;end < s.size(); ++end) {
... 阅读全帖
Q*****a
发帖数: 33
30
来自主题: JobHunting版 - Google onsite 题目求助
string LongestMostTwoSubString(string s) {
printf("s.size():%dn", s.size());
// assume char in s are all ASCII, otherwise we can unsigned char and
256 slots
vector charCounts(128, 0);
int maxStart = 0;
int maxLen = 0;
int start = 0, end = 0;
for (;;) {
while (end < s.size() && ++charCounts[s[end]] <= 2) ++end;
int len = end - start;
if (len > maxLen) {
maxStart = start;
maxLen = len;
}
if (end == s.s... 阅读全帖
Q*****a
发帖数: 33
31
来自主题: JobHunting版 - Google onsite 题目求助
这个偶审题错误,原题是要求如同aaaaabbb这样最多不超过两个不一样的字符构成的子
串,我理解成如abcdabcd这种每个字符出现最多不超过两次。代码没有sally216的简洁
,不过个人习惯解这种区间问题的时候这么写了。顺便鄙视一下买买提的发文超时,居
然没有在session里保存,辛苦敲了半天的东西都没了。telnet时代就有的功能居然都
没实现。
string LongestMostTwoCharsSubString(string s) {
// assume char in s are all ASCII, otherwise we can unsigned char and
256 slots
vector charCounts(128, 0);
int maxStart = 0;
int maxLen = 0;
int start = 0, end = 0;
int uniqCharCounts = 0;
for (;;) {
for (;end < s.size(); ++end) {
... 阅读全帖
p***y
发帖数: 637
32
貌似现在得写得滚瓜烂熟?比如g面试的人对思路,研究啥的好像很没兴趣,就坐等看
最优解的节奏。
有点走火入魔的感觉。如果我是hm,肯定希望找的是能解决陌生问题,思路好的,不是
一听见问题马上根据标准答案写程序的。
具体工作中的问题大部分没人知道最优解,只能从合理trade off的解开始,先实现,
测试,实践,然后在根据需要进行优化。比如,很多production code的搜索,都是直
接顺序查找。因为代码里经常存在需要从三五个值里头匹配一个的。这种匹配只有发现
数据量较大,搜索成为瓶颈时,才改为哈希表或bst之类。
另外,很多面试题要求对特定情况实现一个特定的优化解,把通常nlogn的算法变成n,
这个在实践中常常不鼓励,因为需求变化非常快,一旦需要支持一般情况,之前的优化
努力就白费了。这是大量活生生实例告诉我们的。最典型的是很多字符串处理程序都耗
费大量人力针对ascii字符集和英语的特性优化,等要支持国际语言时,多数优化就无
效了。
不过话说回来,如果背题就能拿20万的package,那么背题还是非常值得的。只是工作
中不要套用做题时候的思路(期望一把得到最优解,揪住特殊条件优... 阅读全帖
v***t
发帖数: 13
33
来自主题: JobHunting版 - 国庆节 狗家面经
请教Autocomplete那题,用trie的话,怎么处理非ASCII和多机并行?
x**********a
发帖数: 1372
34
来自主题: JobHunting版 - 真羡慕CS科班出身的马公的记忆力
请问什么是ascii?这种语言有什么优势?
多谢。
k*******n
发帖数: 16
35
来自主题: JobHunting版 - 贡献一道电面/校招题目
模式有任意多种,理论上ascii都行
f*****g
发帖数: 887
36
来自主题: JobHunting版 - 贡献一道电面/校招题目
如果ascii码多了没法这么处理吧

现在
k*******n
发帖数: 16
37
来自主题: JobHunting版 - 贡献一道电面/校招题目
模式有任意多种,理论上ascii都行
f*****g
发帖数: 887
38
来自主题: JobHunting版 - 贡献一道电面/校招题目
如果ascii码多了没法这么处理吧

现在
l*********u
发帖数: 19053
39
来自主题: JobHunting版 - 这道Amazon面试题什么意思?
本懒蛋记ascii table方法 :)
A=65,a=97
so, toLower(x)=toUpper(x)+(97-65) ? :)
k***g
发帖数: 166
40
来自主题: JobHunting版 - unordered_set是怎么实现的?
如果存的是ascii字符,最理想就是用一个256大小的数组来存
那么对于其他情况呢?比如unordered_set, 或者unordered_set
是怎样尽可能保证O(1)的呢?
J*******i
发帖数: 2162
41
来自主题: JobHunting版 - 这玩意儿是码农的标配吧?
什么样的码农天天背ascii啊?
b*******y
发帖数: 35
42
来自主题: JobHunting版 - A家店面栽在一个老中手里
这是第二轮店面。第一轮一个印度大叔,还不错。
***** Zhang, 一个任性,而又愚蠢的老中。
题目很简单,字符串去掉冗余字符。
int a[256];
char ch; //是字符串中的一位。
....
a[ch] = 1;
这个货反复质问我,ascii码怎么能用作数组index。无知但有底气。
最后还以教训的口气说,想好了再写。谁不是写完code再纠错?
一把年纪,受此大辱,没法混了。
a**********0
发帖数: 422
43
来自主题: JobHunting版 - A家店面栽在一个老中手里
而且如果出题人限定ascii 那数组大小是128 也不是256啊
p******e
发帖数: 528
44
来自主题: JobHunting版 - A家店面栽在一个老中手里
我有个问题, 如果在这个字符串里边存的东西是个特殊的字符,那么是否会有可能这些
字符根本不在ascii (0-255)的字符集里边呢?

发帖数: 1
45
来自主题: JobHunting版 - A家店面栽在一个老中手里
using char as array index is strange, unless you have particular reason.
and ascii code should be positive number, is it right? I am confused.
b*******y
发帖数: 35
46
来自主题: JobHunting版 - A家店面栽在一个老中手里
***** Zhang (*****是英文名)。曝他全名也没必要,也没多大仇恨。
他疑惑的不是字符s[0]的符号,因为我说了可以cast,用uint8(s[0]),对任何平台的
编译器都没问题。
他疑惑的是,字符比如'a'怎么可以做数组的索引。他觉得'a'是ASCII码,是文字。他
不知道'a'也是数字。显得很无知。
b**********5
发帖数: 7881
47
来自主题: JobHunting版 - A家店面栽在一个老中手里
u r kidding right.. i think the interviewer is a bit stuck up, he should
just let the interviewee pass. But to say that java programmer is worse
than a C programmer, is just ludicrous...
and the point about not being ascii is totally valid... this int[] shit is
just not right in that case...

逼,
arbitrarily
p********y
发帖数: 5044
48
来自主题: JobHunting版 - 刚学编程,ascii老出错,求助
0基础,刚刚上Andrew的machine learning,第一次写作业,在textedit上填code,然
后octave 跑一下,结果逗号的地方老说我错了,google了一整天原因,都找不出来,
我直接从别的地方拷贝逗号过来,也还是出错。整个周末都在折腾这个逗号,学习的热
情被打击得好惨啊。。。忘说了,我用的是苹果的电脑,已经把textedit上的所有的
smart substitutions功能都关了
parse error near line 19 of file /Users/Susan/Dropbox/Machine Learning/
machine-learning-ex1/ex1/plotData.m
syntax error
>>> plot(x,y,'rx’,'MarkerSize',10);
^
error: called from:
error: /Users/Susan/Dropbox/Machine Learning/machine-learning-ex1/ex... 阅读全帖

发帖数: 1
49
来自主题: JobHunting版 - 刚学编程,ascii老出错,求助
rx右边单引号
B*********a
发帖数: 6244
50
来自主题: JobHunting版 - 刚学编程,ascii老出错,求助
遇到这种情况,先自己手打一遍再说
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)