V2EX 第 402565 号会员,加入于 2019-04-17 14:39:59 +08:00
今日活跃度排名 5449
zzzrf 最近回复了
8 小时 27 分钟前
回复了 zzzrf 创建的主题 编程 微软面试题:三数之和 II
@Deepseafish 不好意思,弄反了~
13 天前
回复了 zzzrf 创建的主题 Java 亚马逊面试题:尽量减少恶意软件的传播 II
@LGA1150 不好意思,放错了~
28 天前
回复了 zzzrf 创建的主题 LeetCode 字节跳动面试题:滑动拼图 II
@yazoox 字节现在好像确实有点卷,别人算法题一两道,它直接上卷子……
@zrp1994 是的!感谢大佬! 终于会做了!总时间复杂度 O(nlogn)+O(n2)=O(n2)O(nlogn)+O(n2)=O(n2),空间的就是常量空间 O(1)
@Luckydesigner 好滴,谢谢!
86 天前
回复了 zzzrf 创建的主题 程序员 北美字节(Tik ToK)的题难到逆天了
@user8341 四套题,但是题库就那么多,我看到整理了一些,不知道有没有漏的
86 天前
回复了 zzzrf 创建的主题 程序员 北美字节(Tik ToK)的题难到逆天了
@20015jjw OA 就那么卡么,好像连 DS 都是这套题
86 天前
回复了 zzzrf 创建的主题 程序员 北美字节(Tik ToK)的题难到逆天了
86 天前
回复了 zzzrf 创建的主题 程序员 北美字节(Tik ToK)的题难到逆天了

3. Incremental Memory Leak
Jina recently got a computer with two memory sticks. The computer will allocate requested
memory from the largest available memory stick if possible (or from the first memory stick
if both have the same available memory), if neither of these two memory sticks has enough
available memory, it will cause the computer Out of Memory (a.k.a ооM).
Jina is so exciting and writes down a hello world program, but soon Jina observes a
memory leak on her program, her program will allocate i bytes at the i-th second starting
from when the program started. Jina is very curious when the computer will be OOM after
starting her program and the available memory of each memory stick when Oом. Can you
help her figure it out?
The first line of the input gives the number of test cases N. And N cases follow. Each test
case consists of a single line containing two integers M1 and M2 indicating the total
memory in bytes of the first and second memory stick in Jina's computer before starting
Jina's program.
For each test case, output one line containing three integers t, m1, m2, where t is the time
in seconds that computer will be OOM after starting the program, and m1, m2 are the
available memory in bytes of the first and second memory sticks, respectively, when Jina's
computer OOM.
1 <= M1 <= 10 ∧ 18
1 <= M2 <= 10 ∧ 18
2 2
8 11
3 1 0
6 0 4
For test case 1:
0s:2 2
1s:1 2
2s:1 0
3s: OOM
For test case 2:
0s:8 11
1s:8 10
2s:8 8
3s:5 8
4s:5 4
5s:0 4

4. Minimum Character Transformation
A character transformation T(char1, char2) of a string is defined as converting all char1's
within that string into char2's.
For example, T('t', 's') for string "tiktok" will result in "siksok" by replacing all letter 't' with
letter 's'.
Now you are given 2 strings, named source and target, of equal length. Both of them
consist of lowercase characters only.
Find the minimum number of character transformations needed in order to convert
source to target. If the conversion from source to target is not possible, return -1 instead.
Input Constraints.
• 1 <= length(source) = length(target) <= 25, (they won't contain all 26 lowercase
Example 1
Input: source = "aaa", target = "bbb"
Result: 1
// Explanation: only 1 character transformation from letter 'a' to 'b' is needed.
Example 2
Input: source = "ababcc", target = "ccc
Result: 2
// Explanation: 2 character transformations are needed .
// T1('a' => 'b'): "ababcc" => "bbbcc"
// T2('b' => 'c'): "bbbbcc" => "ccсссс"
Example 3
Input: source = "ab", target = "ba"
Result: 3
// Explanation: You cannot directly do 'a' => 'b', which will transform "ab" to "bb".
// T1('a' => 'c'): "ab" => "cb"
// T2('b' => 'a'): "cb" => "ca"
// T3('c' => 'b'): "ca" => "ba"
Example 4
Input: source = 'abac', target =' wxyz '
Result: -1
5. Find Maximum Summationof Subarray
Given an integer array nums, find the contiguous subarray (containing at least one
number) which has the largest sum and return its sum.
Example 1:
Input:[-2, 1, -3, 4, -1, 2, 1, -5, 4]
Output: 6
Explanation: [4, -1, 2, 1] has the largest sum = 6.
Example 2:
Input: [ 2 ]
Output: 2
Example 3:
Input:[-1, 0, -2]
output : 0

6. Version Control
In Bytedance, we publish countless new features on hundreds of different services every
day. Version control is a very important thing for different new features.
We must ensure that this new feature only works for users who have installed the specified
or newer version.
Now we need to design a version comparison algorithm to protect our system.
A version can be made up of major.minor.patch-{pre-release} that they splitted by dot,
where minor, patch and (pre-release) are optional, in which pre-release can be any word.
Like 1.0.0, 2.0, 3, 4.1.1-alpha
The comparison rules for versions are as follows We start with the major, then the minor,
then the patch.
Design a algorithm to return if version1 is greater or equal to version2 1 means greater, 0
means equal, -1 means smaller When major, minor, and patch are equal, a pre-release
version has lower precedence than a normal version
version1 = 1.0.1, version2 = 1.0.0
versionl = 1.0.1, version2 = 1
version1 = 1.01, version2 = 1. 001
Explanation: Ignoring leading zeroes, both "01" аnd
"ѲѲ1" rерrеѕеnt thе ѕаmе іntеgеr "1".
versionl = 1.0.0-alpha, version2 = 1.0.0
Explanation: When major, minor, and patch are equal, a pre-release version has lower
precedence than a normal version

7. Select Pairs
Give a list of positive integer. Each turn, you need to select two numbers x and у out and
do a calculation. The result will be abs(x - у) and the number will be put back to the list if it
is not 0.
At the end, there is at most 1 number left.Return the smallest possible number left.
(It is 0 if no number left.)
The array will be [2,7,4,1,8,1], which will be the input of the function you need to write,
the first 6 means that there will be 6 elements in the array
Combining 2 and 4 to get 2 so the array converts to [2,7,1,8,1] then,
Combining 7 and 8 to get 1 so the array converts to [2,1,1,1] then,
Combining 2 and 1 to get 1 so the array converts to [1,1,1] then,
Combining 1 and 1 to get 0 so the array converts to [1] then that's the optimalvalue
关于   ·   帮助文档   ·   FAQ   ·   API   ·   我们的愿景   ·   广告投放   ·   感谢   ·   实用小工具   ·   4324 人在线   最高记录 5497   ·     Select Language
World is powered by solitude
VERSION: · 18ms · UTC 09:58 · PVG 17:58 · LAX 01:58 · JFK 04:58
♥ Do have faith in what you're doing.