由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - How to elegantly solve this interview question?
相关主题
BB onsite惨败而归 血的教训!java中这个是什么operator“>>>="
一道G老题counting quickperm algorithm
问个bitwise实现加法的问题 (转载)问一个L的题目
BB的面试题-只用&和| 如何reverse a bit string?FLG面试题,压缩整数 (转载)
来贡献个小题.请问这段代码什么意思?
关于permutation和combinationLinkedIn Data Scientist, Machine Learning 电面
c++ is too nasty也贴个转罗马数字的code
leetcode上的2个整数相除贡献个regular expression DP解法
相关话题的讨论汇总
话题: shift话题: result话题: elegantly话题: unsigned话题: would
进入JobHunting版参与讨论
1 (共1页)
a********r
发帖数: 218
1
Given the character array {‘a’,’b’,’c’,’d’,’e’,’f’,’g’,’h’}
create a function/method that can shift the characters to the right by a
number of iterations specified in a parameter.
the prototype would look like:
void shift(char *arry, unsigned int length, unsigned int shift_count);
A call to this method with a shift count of 1 would return the result {’h’
,‘a’,’b’,’c’,’d’,’e’,’f’,’g’} , and 5 would return the result
{‘d’,’e’,’f’,’g’,’h’,’a’,’b’,’c’}.
Thanks so much!
c****p
发帖数: 6474
2
abcdefgh -> cba hgfed -> defgh abc

}
result

【在 a********r 的大作中提到】
: Given the character array {‘a’,’b’,’c’,’d’,’e’,’f’,’g’,’h’}
: create a function/method that can shift the characters to the right by a
: number of iterations specified in a parameter.
: the prototype would look like:
: void shift(char *arry, unsigned int length, unsigned int shift_count);
: A call to this method with a shift count of 1 would return the result {’h’
: ,‘a’,’b’,’c’,’d’,’e’,’f’,’g’} , and 5 would return the result
: {‘d’,’e’,’f’,’g’,’h’,’a’,’b’,’c’}.
: Thanks so much!

r*******y
发帖数: 1081
3
revese twice ?

}
result

【在 a********r 的大作中提到】
: Given the character array {‘a’,’b’,’c’,’d’,’e’,’f’,’g’,’h’}
: create a function/method that can shift the characters to the right by a
: number of iterations specified in a parameter.
: the prototype would look like:
: void shift(char *arry, unsigned int length, unsigned int shift_count);
: A call to this method with a shift count of 1 would return the result {’h’
: ,‘a’,’b’,’c’,’d’,’e’,’f’,’g’} , and 5 would return the result
: {‘d’,’e’,’f’,’g’,’h’,’a’,’b’,’c’}.
: Thanks so much!

r*******n
发帖数: 344
4
abcdefgh -> abcdefghabcdefgh -> abc defghabc defgh
从index = length - shift_count 开始截取长度为length的array

}
result

【在 a********r 的大作中提到】
: Given the character array {‘a’,’b’,’c’,’d’,’e’,’f’,’g’,’h’}
: create a function/method that can shift the characters to the right by a
: number of iterations specified in a parameter.
: the prototype would look like:
: void shift(char *arry, unsigned int length, unsigned int shift_count);
: A call to this method with a shift count of 1 would return the result {’h’
: ,‘a’,’b’,’c’,’d’,’e’,’f’,’g’} , and 5 would return the result
: {‘d’,’e’,’f’,’g’,’h’,’a’,’b’,’c’}.
: Thanks so much!

c****p
发帖数: 6474
5
需要O(n)空间

【在 r*******n 的大作中提到】
: abcdefgh -> abcdefghabcdefgh -> abc defghabc defgh
: 从index = length - shift_count 开始截取长度为length的array
:
: }
: result

a********r
发帖数: 218
6
@chenpp,
you are genius!!!!!

【在 c****p 的大作中提到】
: 需要O(n)空间
r*******n
发帖数: 344
7
For in-place replacement, yours is better.

【在 c****p 的大作中提到】
: 需要O(n)空间
f*******t
发帖数: 7549
8
好办法,赞

【在 c****p 的大作中提到】
: abcdefgh -> cba hgfed -> defgh abc
:
: }
: result

c****p
发帖数: 6474
9
谬赞。。
编程之美上的样题。

【在 a********r 的大作中提到】
: @chenpp,
: you are genius!!!!!

a********r
发帖数: 218
10
Given the character array {‘a’,’b’,’c’,’d’,’e’,’f’,’g’,’h’}
create a function/method that can shift the characters to the right by a
number of iterations specified in a parameter.
the prototype would look like:
void shift(char *arry, unsigned int length, unsigned int shift_count);
A call to this method with a shift count of 1 would return the result {’h’
,‘a’,’b’,’c’,’d’,’e’,’f’,’g’} , and 5 would return the result
{‘d’,’e’,’f’,’g’,’h’,’a’,’b’,’c’}.
Thanks so much!
相关主题
关于permutation和combinationjava中这个是什么operator“>>>="
c++ is too nastycounting quickperm algorithm
leetcode上的2个整数相除问一个L的题目
进入JobHunting版参与讨论
c****p
发帖数: 6474
11
abcdefgh -> cba hgfed -> defgh abc

}
result

【在 a********r 的大作中提到】
: Given the character array {‘a’,’b’,’c’,’d’,’e’,’f’,’g’,’h’}
: create a function/method that can shift the characters to the right by a
: number of iterations specified in a parameter.
: the prototype would look like:
: void shift(char *arry, unsigned int length, unsigned int shift_count);
: A call to this method with a shift count of 1 would return the result {’h’
: ,‘a’,’b’,’c’,’d’,’e’,’f’,’g’} , and 5 would return the result
: {‘d’,’e’,’f’,’g’,’h’,’a’,’b’,’c’}.
: Thanks so much!

r*******y
发帖数: 1081
12
revese twice ?

}
result

【在 a********r 的大作中提到】
: Given the character array {‘a’,’b’,’c’,’d’,’e’,’f’,’g’,’h’}
: create a function/method that can shift the characters to the right by a
: number of iterations specified in a parameter.
: the prototype would look like:
: void shift(char *arry, unsigned int length, unsigned int shift_count);
: A call to this method with a shift count of 1 would return the result {’h’
: ,‘a’,’b’,’c’,’d’,’e’,’f’,’g’} , and 5 would return the result
: {‘d’,’e’,’f’,’g’,’h’,’a’,’b’,’c’}.
: Thanks so much!

r*******n
发帖数: 344
13
abcdefgh -> abcdefghabcdefgh -> abc defghabc defgh
从index = length - shift_count 开始截取长度为length的array

}
result

【在 a********r 的大作中提到】
: Given the character array {‘a’,’b’,’c’,’d’,’e’,’f’,’g’,’h’}
: create a function/method that can shift the characters to the right by a
: number of iterations specified in a parameter.
: the prototype would look like:
: void shift(char *arry, unsigned int length, unsigned int shift_count);
: A call to this method with a shift count of 1 would return the result {’h’
: ,‘a’,’b’,’c’,’d’,’e’,’f’,’g’} , and 5 would return the result
: {‘d’,’e’,’f’,’g’,’h’,’a’,’b’,’c’}.
: Thanks so much!

c****p
发帖数: 6474
14
需要O(n)空间

【在 r*******n 的大作中提到】
: abcdefgh -> abcdefghabcdefgh -> abc defghabc defgh
: 从index = length - shift_count 开始截取长度为length的array
:
: }
: result

a********r
发帖数: 218
15
@chenpp,
you are genius!!!!!

【在 c****p 的大作中提到】
: 需要O(n)空间
r*******n
发帖数: 344
16
For in-place replacement, yours is better.

【在 c****p 的大作中提到】
: 需要O(n)空间
f*******t
发帖数: 7549
17
好办法,赞

【在 c****p 的大作中提到】
: abcdefgh -> cba hgfed -> defgh abc
:
: }
: result

c****p
发帖数: 6474
18
谬赞。。
编程之美上的样题。

【在 a********r 的大作中提到】
: @chenpp,
: you are genius!!!!!

b*********6
发帖数: 19
19
Yes,编程珠矶上有这道题目。
q********c
发帖数: 1774
20
Facebook phone interview question?
p*******o
发帖数: 3564
21
deque? O(n) extra space
1 (共1页)
进入JobHunting版参与讨论
相关主题
贡献个regular expression DP解法来贡献个小题.
C++高手看下这个LC的LRU Cache的实现关于permutation和combination
一道qualcomm面試題c++ is too nasty
讨论一道面试题leetcode上的2个整数相除
BB onsite惨败而归 血的教训!java中这个是什么operator“>>>="
一道G老题counting quickperm algorithm
问个bitwise实现加法的问题 (转载)问一个L的题目
BB的面试题-只用&和| 如何reverse a bit string?FLG面试题,压缩整数 (转载)
相关话题的讨论汇总
话题: shift话题: result话题: elegantly话题: unsigned话题: would