Tiktok VO 真题

随着tiktok的OA很多人经过我们的辅助通过了OA之后,tiktok的VO也迎来了众多的算法题,下面来看看近期出现过的真题吧

First Unique Character

Description

A unique character is one that appears only once in a string. Given a string consisting of lowercase English letters only, return the index of the first occurrence of a unique character in the string using 1-based indexing. If the string does not contain any unique character, return -1.

Example

s = "statistics"

The unique characters are [a, c] among which a occurs first. Using 1-based indexing, it is at index 3.

Function Description

Complete the function getUniqueCharacter in the editor below.

getUniqueCharacter has the following parameter(s):

  • string s: a string

Returns

  • int: either the 1-based index or -1

Constraints

  • 1 ≤ length of s ≤ 10^5
  • The string s consists of lowercase English letters only.

Sample Case 0

Sample Input For Custom Testing

hackthegame

Sample Output

3

Explanation

The unique characters are [c, k, t, g, m] out of which the character c occurs first, at index 3.

获取更多面经,面试辅助,代面试,请联系我

If you're afraid that you can't solve the OA on your own, please scan the code to contact me or telegram

Leave a Reply

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