[LeetCode] Count Prefixes of a Given String

2255. Count Prefixes of a Given String

You are given a string array words and a string s, where words[i] and s comprise only of lowercase English letters.

Return the number of strings in words that are a prefix of s.

A prefix of a string is a substring that occurs at the beginning of the string. A substring is a contiguous sequence of characters within a string.

Read more
[Code Jam 2022 Round 1C] Letter BlocksRead more
[Codeforces] Round #770 (Div. 2) B. Fortune TellingRead more
[BOJ] 9240 로버트 후드Read more
[BOJ] 10254 고속도로Read more
[BOJ] 8927 SquaresRead more
[BOJ] 7420 맹독 방벽Read more
[BOJ] 2254 감옥 건설Read more
[LeetCode] Fancy Sequence

1622. Fancy Sequence

Write an API that generates fancy sequences using the append, addAll, and multAll operations.

Implement the Fancy class:

  • Fancy() Initializes the object with an empty sequence.
  • void append(val) Appends an integer val to the end of the sequence.
  • void addAll(inc) Increments all existing values in the sequence by an integer inc.
  • void multAll(m) Multiplies all existing values in the sequence by an integer m.
  • int getIndex(idx) Gets the current value at index idx (0-indexed) of the sequence modulo 109 + 7. If the index is greater or equal than the length of the sequence, return -1.
Read more
[LeetCode] 2 Keys Keyboard

650. 2 Keys Keyboard

There is only one character ‘A’ on the screen of a notepad. You can perform one of two operations on this notepad for each step:

  • Copy All: You can copy all the characters present on the screen (a partial copy is not allowed).
  • Paste: You can paste the characters which are copied last time.

Given an integer n, return the minimum number of operations to get the character ‘A’ exactly n times on the screen.

Read more