#!/usr/bin/env python import re if __name__ == ‘__main__’: lines = [line.rstrip(‘\n’) for line in open(‘file.json’)] ids = set() for line … More
Category: Uncategorized
An algorithm to find the smallest positive integer that does not occur in a given array.
Following examples. [1, 3, 6, 4, 1, 2, 7] then return 5 [-1, 1, 2, 3] the return 4 [−1, … More
An algorithm that checks if the values of an array form one or two numerical sequences starting from 1
If the values of the array can form one or two numerical sequences then return 1 otherwise return 0. For example … More
[Java8] – How to check if all values in an array are equals?
public boolean isAllValuesEquals(int[] Arr ){ if ( Arrays.stream(Arr).distinct().count() == 1 ) { return true; } return false; }
[Java] – How to concatenate two arrays?
public int[] joinArrays(int[] int1, int[] int2) { int[] result = new int[Arr.length]; System.arraycopy( int1, 0, result, 0, int1.length); System.arraycopy( int2, … More
[Git] – How to get a PR made for the upstream repo made for another person?
To check out the PR: git fetch upstream pull/<PR number>/head:pr git checkout pr To push for his/her fork: git push … More
[NodeJS] – How to update all dependencies into `package.json` file to the latest version?
npm i -g npm-check-updates npm-check-updates -u npm install
[NodeJS] – How to install your npm project to test it locally as a module?
Use the command: `$ npm link .` After running this command the npm will create a symlink in the global folder{prefix}/lib/node_modules/<package> In this … More
[Git] – How to make rebase/squash?
git rebase -i HEAD~<numbercommits>
[NodeJS] – Summary Packages Prefix
How to use the prefix into the `package.json` file? How are the means of prefix? Examples (~)version “Approximately equivalent to … More