注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
本帖最后由 匿名 于 2025-9-14 17:09 编辑
总共75分钟5道题,难度不大,求米。
Question 1
Write a function that, given an integer X, returns an integer that corresponds to the minimum number of steps required to change X to a Fibonacci number.
In each step you can either increment or decrement the current number, i.e., you can change X to either X + 1 or X – 1.
X will be between 0 and 1,000,000 inclusive.
The Fibonacci sequence is defined as follows:F[0] = 0
F[1] = 1
for each i >= 2: F[i] = F[i-1] + F[i-2]
The elements of the Fibonacci sequence are called Fibonacci numbers.
Examples:- For X = 15 the function should return 2.
- For X = 1 or X = 13 the function should return 0.
Question 2
Write a function that, given a zero-indexed array A consisting of N integers representing the initial test scores of a row of students, returns an array of integers representing their final test scores (in the same order).
There is a group of students who sit next to each other in a row. Each day, the students study together and take a test at the end of the day. Test scores for a given student can only change once per day as fsize="4">Question 5
Write a function that, given a string S, returns an integer that represents the number of ways we can select a non-empty substring of S in which all of the characters are identical.
Example:- The string "zzzyz" contains 8 such substrings:
- Four instances of "z",
- Two of "zz",
- One of "zzz",
- And one of "y".
- String "k" contains only one such substring: "k".
You may assume that the length of S is between 1 and 100, and each character in S is a lowercase letter (a–z). |