登录
  • #刷题
  • #careercup

【第三轮】7.24-7.31 CareerCup 5.1

林微熙
1077
9
5.1 You are given two 32-bit numbers, N andM, and two bit positions, i and j. Write a method to insert M into Nsuch that M starts at bit j and ends at bit i. You can assume that the bits j through i have enough space to fit all ofM. That is, ifM= 10011, you can assume that there are at least 5 bits between j and i. You would not, for example, have j-3 and i=2, because M could not fully fit between bit 3 and bit 2.

EXAMPLE:

Input: N = 16000000000, M = 10011, i = 2, j = 6

Output: N = 10001001100

回复解法可以按照以下格式来

[indent][indent]【解题思路】

【时间复杂度】

【空间复杂度】

【gist link】

---------------OPTional,如果觉得test case比较好,欢迎写出来分享----------------------

【test case】[/indent]


[/indent]

Notice:

1、记得在程序注释中表明自己算法的时间、空间复杂度

2、代码难懂之处加注释

3、每道题目有对应的帖子,除了贴解法,欢迎讨论,集思广益

4、任何未尽之处,欢迎回报名帖提问,我会进一步作出修改

不知道原组织者是不是有什么事情了

我就冒昧继续贴了

**求大牛们继续抛砖引玉啊
9条回复
热度排序

发表回复