Skip to main content

· One min read

【請求項 4】 少なくとも 2 つのレベルのうちの最高および 2 番目に高いレベル以外のレベルの各鍵に 対して、前記ソルトは、さらに親鍵を生成するための前記ソルト内の各第 1 キーワードを 含む請求項 3 に記載のデジタル ID 管理方法。

please rewrite the sentence above based on the following claim 4.

claim 4 The method according to claim 7, wherein for each key in a level other than the highest and a second highest level among the at least two levels, the salt further comprises each keyword in the salt for generating the parent key and parent keys(s) in previous levels.

· 2 min read
Abraham Fig

Given an integer array nums, return the sum of divisors of the integers in that array that have exactly four divisors. If there is no such integer in the array, return 0.

Example

Example 1:

Input: nums = [21,4,7] Output: 32

Explanation: 21 has 4 divisors: 1, 3, 7, 21 4 has 3 divisors: 1, 2, 4 7 has 2 divisors: 1, 7 The answer is the sum of divisors of 21 only.

Example 2:

Input: nums = [21,21] Output: 64

Example 3:

Input: nums = [1,2,3,4,5] Output: 0

Constraints:

1 <= nums.length <= 104 1 <= nums[i] <= 105

/**
* @param {number[]} nums
* @return {number}
*/

const findDivisors = (num) => {
const divisors = [1, num];
const upperLimit = Math.sqrt(num);
if (Number.isInteger(upperLimit)) {
return [];
// divisors.push(upperLimit)
}
for (let i = 2; i < upperLimit; i++) {
if (Number.isInteger(num / i)) {
divisors.push(i);
divisors.push(num / i);
}
if (divisors.length > 4) {
return [];
}
}
if (divisors.length === 4) {
return divisors;
} else {
return [];
}
};
var sumFourDivisors = function (nums) {
const res = [];
const length = nums.length;
for (let i = 0; i < length; i++) {
res.push(findDivisors(nums[i]).reduce((prev, cur) => prev + cur, 0));
}
return res.reduce((prev, cur) => prev + cur, 0);
};

· 2 min read
Abraham Fig

Given two integers n and k, return an array of all the integers of length n where the difference between every two consecutive digits is k. You may return the answer in any order.

Note that the integers should not have leading zeros. Integers as 02 and 043 are not allowed.

Example

Example 1:

Input: n = 3, k = 7 Output: [181,292,707,818,929] Explanation: Note that 070 is not a valid number, because it has leading zeroes. Example 2:

Input: n = 2, k = 1 Output: [10,12,21,23,32,34,43,45,54,56,65,67,76,78,87,89,98]

Constraints:

2 <= n <= 9 0 <= k <= 9

/**
* @param {number} n
* @param {number} k
* @return {number[]}
*/
var numsSameConsecDiff = function (n, k) {
let results = new Set();
function travel(arr) {
if (arr.length === n) {
results.add(Number(arr.join("")));
} else if (arr.length < n) {
const last = arr[arr.length - 1];
const plus = last + k;
const minus = last - k;
if (plus >= 0 && plus <= 9) {
travel([...arr, plus]);
}
if (minus >= 0 && minus <= 9) {
travel([...arr, minus]);
}
}
}
for (let i = 1; i < 10; i++) {
travel([i]);
}
return [...results];
};

· One min read
Abraham Fig

Given a 2D integer array matrix, return the transpose of matrix.

Given the array of integers nums, you will choose two different indices i and j of that array. Return the maximum value of (nums[i]-1)*(nums[j]-1).

Example

Example 1:

Input: nums = [3,4,5,2] Output: 12 Explanation: If you choose the indices i=1 and j=2 (indexed from 0), you will get the maximum value, that is, (nums[1]-1)(nums[2]-1) = (4-1)(5-1) = 3*4 = 12. Example 2:

Input: nums = [1,5,4,5] Output: 16 Explanation: Choosing the indices i=1 and j=3 (indexed from 0), you will get the maximum value of (5-1)*(5-1) = 16. Example 3:

Input: nums = [3,7] Output: 12

/**
* @param {number[]} nums
* @return {number}
*/
var maxProduct = function (nums) {
nums.sort((a, b) => a - b);
const len = nums.length;
return (nums[len - 1] - 1) * (nums[len - 2] - 1);
};

· One min read
Abraham Fig

Here is my Zsh Setting.

~/.zshrc

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion

autoload -Uz vcs_info
precmd() { vcs_info }
zstyle ':vcs_info:git:*' formats '(%b)'
setopt PROMPT_SUBST
PROMPT='%n in ${PWD/#$HOME/~} %F{green}${vcs_info_msg_0_} %F{reset_color}> '

· 2 min read
Abraham Fig

Given a binary search tree (BST), find the lowest common ancestor (LCA) node of two given nodes in the BST.

According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes p and q as the lowest node in T that has both p and q as descendants (where we allow a node to be a descendant of itself).”

Example

Example 1:

Input: root = [6,2,8,0,4,7,9,null,null,3,5], p = 2, q = 8 Output: 6 Explanation: The LCA of nodes 2 and 8 is 6.

Example 2:

Input: root = [6,2,8,0,4,7,9,null,null,3,5], p = 2, q = 4 Output: 2 Explanation: The LCA of nodes 2 and 4 is 2, since a node can be a descendant of itself according to the LCA definition.

/**
* Definition for a binary tree node.
* function TreeNode(val) {
* this.val = val;
* this.left = this.right = null;
* }
*/

/**
* @param {TreeNode} root
* @param {TreeNode} p
* @param {TreeNode} q
* @return {TreeNode}
*/
var lowestCommonAncestor = function (root, p, q) {
let pPath = [];
let qPath = [];
let path = [];
function travel(node) {
if (node) {
path.push(node);
if (node === p) {
pPath = path.slice(0);
}
if (node === q) {
qPath = path.slice(0);
}
travel(node.left);
travel(node.right);
path.pop();
}
}
travel(root);

let i = 0;
for (; i < pPath.length || i < qPath.length; i++) {
if (pPath[i] !== qPath[i]) {
break;
}
}
return pPath[i - 1];
};

· One min read
Abraham Fig

Given a 2D integer array matrix, return the transpose of matrix.

The transpose of a matrix is the matrix flipped over its main diagonal, switching the matrix's row and column indices. link: https://leetcode.com/problems/transpose-matrix/

Example

Example 1:

Input: matrix = [[1,2,3],[4,5,6],[7,8,9]] Output: [[1,4,7],[2,5,8],[3,6,9]]

Example 2:

Input: matrix = [[1,2,3],[4,5,6]] Output: [[1,4],[2,5],[3,6]]

/**
* @param {number[][]} matrix
* @return {number[][]}
*/
var transpose = function (matrix) {
if (!matrix.length) return;
const numOfCols = matrix[0].length;
const numOfRows = matrix.length;
const result = [];
for (let i = 0; i < numOfCols; i++) {
result.push([]);
}
for (let i = 0; i < numOfCols; i++) {
for (let j = 0; j < numOfRows; j++) {
result[i][j] = matrix[j][i];
}
}
return result;
};

· One min read
Abraham Fig

PWA One is a digital identity manager, which is still under construction.

Why a digital identity project is named as outis? Because it is a Greek word, which means "nobody". It is a reference to the character in the Odyssey, who blinded the cyclops Polyphemus and then escaped by telling him that his name was "nobody".

I wish to be a nobody and a everybody in the digital world, and I wish you can be a nobody too, if you don't want to be traced.

tip

There are some other features I wish to implement in the future, find them in the other posts.

how to use PWA test version

  1. install PWA One PWA

    1.1 open https://www.iamoutis.com/ in your phone

    1.2 find the add to home screen button in the browser menu

    1.3 click Add button to install PWA One PWA

  2. open PWA One app, and create a new identity.

· One min read
Abraham Fig

Welcome to the this new blog!

I am A.F. and I am a full stack engineer. This blog is a place where I will share my thoughts on various topics. I will try to keep the posts short and to the point.

If you feel like buying me a coffee, currently I am working in Singapore.

Enjoy!