LeetCode - 2 Keys Keyboard

Question Definition

Java Solution

public int minSteps(int n) {
    if (n == 1) return 0;
    int res = n;
    for (int i = n - 1; i > 1; --i) {
        if (n % i == 0) {
            res = Math.min(res, minSteps(n / i) + i);
        }
    }
    return res;
}

LeetCode - Word Search

Question Definition

Given a 2D board and a word, find if the word exists in the grid.

The word can be constructed from letters of sequentially adjacent cell, where “adjacent” cells are those horizontally or vertically neighboring. The same letter cell may not be used more than once.

More …

LeetCode - Search for a Range

Question Definition

Given an array of integers sorted in ascending order, find the starting and ending position of a given target value.

Your algorithm’s runtime complexity must be in the order of O(log n).

If the target is not found in the array, return [-1, -1].

More …