[LeetCode] First Missing Positive (Java)

Given an unsorted integer array, find the first missing positive integer. For example, Given [1,2,0] return 3, and [3,4,-1,1] return 2. Your algorithm should run in O(n) time and uses constant space. Analysis We are required to use constant space. So we need to use the array. We can put the element, which value is i, in position i – 1. After … Read more [LeetCode] First Missing Positive (Java)

[LeetCode] Next Permutation (Java)

Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possible, it must rearrange it as the lowest possible order (ie, sorted in ascending order). The replacement must be in-place, do not allocate extra memory. Here are some examples. Inputs are in the left-hand column and … Read more [LeetCode] Next Permutation (Java)

[LeetCode] Letter Combinations of a Phone Number (Java)

Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telephone buttons) is given below.

Note: Although the above answer is in lexicographical order, your answer could be in any order you want. Analysis It’s a easy question. But we … Read more [LeetCode] Letter Combinations of a Phone Number (Java)

Create shortcut in Ubuntu

We may install some software manually. For example, we can run the Idea Intellij by running idea.sh. But it’s not so convenient.  So we can create a shortcut for the problem. Create a Idea.desktop file on the desktop. The content is as follow.

You may need to change the paths in the file and … Read more Create shortcut in Ubuntu