您的位置:首页 > 数据库 > Oracle

oracle面试问题_Oracle编码面试问题

2020-08-17 19:36 1831 查看

oracle面试问题

日常编码问题 (Daily coding problems)

They are a wide variety of questions inspired by real programming interviews, with in-depth solutions that clearly take you through each core concept.

它们是受实际编程访谈启发的各种各样的问题,其深入的解决方案可以使您清楚地了解每个核心概念。

Get exceptionally good at coding interviews by solving one problem every day.

通过每天解决一个问题,特别擅长编码面试。

We will together solve these problems using JavaScript.

我们将一起使用JavaScript解决这些问题。

问题1 (Problem #1)

题 (Question)

We say a number is sparse if there are no adjacent ones in its binary representation.

我们说如果数字的二进制表示中没有相邻的数字,则它是稀疏的。

For example,

Do this in faster than

O(N log N)
time.

这样做的时间比

O(N log N)
时间快。

解 (Solution)

First of all, convert a integer to binary as follows.

首先,将整数转换为二进制,如下所示。

Then we implement the following

get_next_sparse(num)
function that returns the smallest sparse number greater than or equal
num
.

然后,我们实现以下

get_next_sparse(num)
函数,该函数返回大于或等于
num
的最小稀疏数。

We loop through an array of string and break when the current digit and previous digit are equal to the string of 1 and then create the array of zeros as follows.

我们遍历字符串数组,并在当前数字和前一位数字等于字符串1时中断,然后按如下方式创建零数组。

Finally, the output of this solution.

最后,此解决方案的输出。

console.log(get_next_sparse(21))
<< 21console.log(get_next_sparse(25))
<< 32

Easy, right?

容易吧?

I will update new problems that were asked by Oracle in this article, please 🔖 it to read again and get the latest problems and solutions.

我将更新本文中Oracle提出的新问题,请🔖重新阅读以获取最新的问题和解决方案。

Thanks for reading!

谢谢阅读!

翻译自: https://medium.com/javascript-in-plain-english/oracle-coding-interview-questions-5af5f1e13de8

oracle面试问题

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: