CS-OA cs-vo Faang

[2024/01 oracel sde OA] 60分钟四个题两个选择两个算法题

都不难的,每个都是原题。正常准备的话,大概十几分钟能够完成。我们csoahelp完成这次的OA大概花了20分钟左右。

1. 4th Bit

A binary number is a combination of 1s and 0s. Its n[th] least significant digit is the n[th] digit starting from the right starting with 1. Given a decimal number, convert it to binary and determine the value of the 4th least significant digit.

Example

number = 23

  • Convert the decimal number 23 to binary number: 2310=24+23+21+20=(10111)22310​=24+23+21+20=(10111)2​.
  • The value of the 4th index from the right in the binary representation is 0.

Function Description

Complete the function fourthBit in the editor below.

fourthBit has the following parameter(s):

  • int number: a decimal integer

Returns:

  • int: an integer 0 or 1 matching the 4th least significant digit in the binary representation of number.

Constraints

  • 0≤number<2^31

2. Break a Palindrome

A palindrome reads the same from left or right, mom for example. There is a palindrome which must be modified, if possible. Change exactly one character of the string to another character in the range ascii[a-z] so that the string meets the following three conditions:

  • The new string is lower alphabetically than the initial string.
  • The new string is the lowest value string alphabetically that can be created from the original palindrome after making only one change.
  • The new string is not a palindrome.

Return the new string, or, if it not possible to create a string meeting the criteria, return the string IMPOSSIBLE.

Example

palindromeStr = 'aaabbbaaa'

  • Possible strings lower alphabetically than aaabbbaaa after one change are [aaaabaaaa].
  • aaaabaaaa is not a palindrome and is the lowest string that can be created from palindromeStr.

Function Description

Complete the function breakPalindrome in the editor below.

breakPalindrome has the following parameter(s):

  • string palindromeStr: the original string

3. Which of the following operators has the lowest precedence?

  • Ternary operator (?:)
  • Comma operator (,)
  • Sizeof operator (sizeof)
  • Member access operator (.)

4. Are you an expert on data structures?

Which of the following data structures can erase from its beginning or its end in O(1) time?

  • vector
  • deque
  • stack
  • segment tree

更多OA真题咨询,辅助VO OA,欢迎联系我

Leave a Reply

Your email address will not be published. Required fields are marked *