## leetcode 389~399 solution

• 389 Find the Difference
• 390 Elimination Game
• 391 Perfect Rectangle
• 392 Is Subsequence
• 393 UTF-8 Validation
• 394 Decode String
• 395 Longest Substring with At Least K Repeating Characters
• 396 Rotate Function
• 397 Integer Replacement
• 398 Random Pick Index
• 399 Evaluate Division

## leetcode contest 5 solution

• 400 Nth Digit
• 401 Binary Watch
• 402 Remove K Digits
• 403 Frog Jump

## leetcode contest 1 solution

The problems contains:

• 386. Lexicographical Numbers
• 387. First Unique Character in a String
• 388. Longest Absolute File Path

## leetcode Mini Parser

### leetcode Mini Parser

Given a nested list of integers represented as a string, implement a parser to deserialize it.

Each element is either an integer, or a list — whose elements may also be integers or other lists.

Note: You may assume that the string is well-formed:

• String is non-empty.
• String does not contain white spaces.
• String contains only digits 0-9, [, ,, ].

Example 1:

Example 2:

## leetcode Shuffle an Array

### leetcode Shuffle an Array

Shuffle a set of numbers without duplicates.

Example:

## leetcode Ransom Note

### leetcode Ransom Note

Given  an  arbitrary  ransom  note  string  and  another  string  containing  letters from  all  the  magazines,  write  a  function  that  will  return  true  if  the  ransom   note  can  be  constructed  from  the  magazines ;  otherwise,  it  will  return  false.

Each  letter  in  the  magazine  string  can  only  be  used  once  in  your  ransom  note.

Note:
You may assume that both strings contain only lowercase letters.

## leetcode Linked List Random Node

### leetcode Linked List Random Node

Given a singly linked list, return a random node’s value from the linked list. Each node must have the same probability of being chosen.

What if the linked list is extremely large and its length is unknown to you? Could you solve this efficiently without using extra space?

Example:

## leetcode Insert Delete GetRandom O(1) – Duplicates allowed

### leetcode Insert Delete GetRandom O(1) – Duplicates allowed

Design a data structure that supports all following operations in average O(1) time.

Note: Duplicate elements are allowed.

1. insert(val): Inserts an item val to the collection.
2. remove(val): Removes an item val from the collection if present.
3. getRandom: Returns a random element from current collection of elements. The probability of each element being returned is linearly related to the number of same value the collection contains.

Example:

## leetcode Insert Delete GetRandom O(1)

### leetcode Insert Delete GetRandom O(1)

Design a data structure that supports all following operations in O(1) time.

1. insert(val): Inserts an item val to the set if not already present.
2. remove(val): Removes an item val from the set if present.
3. getRandom: Returns a random element from current set of elements. Each element must have the same probability of being returned.

Example: