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

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面试问题

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值