Given array a[n], create array b where b[i] = a[i-1] + a[i] + a[i+1]. Treat out-of-bounds as 0.
Example: Input: n = 5, a = [4, 0, 1, -2, 3] Output: [4, 5, -1, 2, 1]
Explanation:
Build a string by taking characters column-wise from an array of strings.
Example: Input: ["Daisy", "Rose", "Hyacinth", "Poppy"] Output: "DRHPaoyoisapsecpyiynth"
Rules:
You are provided with a set of cards characterized by suits (+, -, =), values (A, B, C), and counts of these values ranging from 1 to 3. Your task is to identify a valid hand from the given cards. A valid hand consists of 3 cards where:
Example 1: Input cards: { +AA, -AA, +AA, -C, -B, +AA, -AAA, -A, =AA }
Valid hands could be:
{ +AA, +AA, +AA }
Suit: Same [+ + +]
Value: Same [A A A]
Count: Same [2 2 2]
{ -A, -AA, -AAA }
Suit: Same [- - -]
Value: Same [A A A]
Count: Different [1 2 3]
Example 2: A valid hand can also be:
{ -A, +BB, =CCC }
Suit: Different [+, -, =]
Value: Different [A B C]
Count: Different [1 2 3]
Given a string and a list of valid letters, count how many words in the string can be formed using the letters in the valid letters list.
Requirements:
Example:
Input:
String: "Hello, I am h2ere!"
Letters: "heloiar"
Output: 3
Explanation:
Valid words: "Hello,", "I", "h2ere!"
Invalid word: "am" (as 'm' is not in valid letters)
Given a matrix of integers field (n × m) and a figure matrix (3 × 3), find valid dropping positions.
Requirements:
Example:
Field:
[[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[1, 1, 0, 1, 0],
[1, 0, 1, 0, 1]]
Figure:
[[1, 1, 1],
[1, 0, 1],
[1, 0, 1]]
Output: 2
Constraints:
Implement a memory allocation system using bit arrays.
Memory Structure:
Query Types:
Input: (0, 5)
Action: Find earliest block with 5 consecutive 0s at start
Return: Starting index or -1
Mark allocated bits as 1
Input: (1, 3)
Action: Release 3rd successful allocation
Return: Size of released memory
Mark bits as 0
Example: Block: [00111111][11111100] Free memory sizes: 2, 0
Convert phone numbers to possible valid words using phone keypad mapping.
Keypad Mapping:
2: 'abc'
3: 'def'
4: 'ghi'
5: 'jkl'
6: 'mno'
7: 'pqrs'
8: 'tuv'
9: 'wxyz'
Requirements:
Example:
Input: '76278'
Output: ['roast', 'smart', 'snast']
Assumptions:
Implement a system to track contract worker hours and compensation.
Level 1: Basic Operations
ADD_WORKER <workerId> <position> <compensation>
REGISTER <workerId> <timestamp>
GET <workerId>
Level 2: Statistics
Level 3: Worker Management
Level 4: Special Time Periods
Example:
Input:
["ADD_WORKER", "john", "engineer", "100"]
["REGISTER", "john", "1000"]
["REGISTER", "john", "1015"]
Output:
["true", "registered", "registered", "15"]
Requirements: