Skip to content

Instantly share code, notes, and snippets.

View NFhbar's full-sized avatar
🎯
Focusing

N F NFhbar

🎯
Focusing
View GitHub Profile
@NFhbar
NFhbar / diagonal.md
Last active July 24, 2020 01:20
Diagonal Matrix

Given a matrix with dimension m * n, write a function called diagonalSort() which sorts the matrix diagonally in ascending order from the top left to the bottom right. Return the sorted matrix.

const matrix = [
  [3,3,1,1],
  [2,2,1,2],
  [1,1,1,2]
]
@NFhbar
NFhbar / intersection.md
Created July 16, 2020 18:39
Array intersection

Array Intersection, 🟢


Problem

Create a function FindIntersection(strArr) that reads an array of strings stored in strArr which will contain 2 elements: the first element will represent a list of comma-separated numbers sorted in ascending order, the second element will represent a second list of comma-separated numbers (also sorted). Your goal is to return a list containing the numbers that occur in elements of strArr in sorted order. If there is no intersection, return an empty array.

Constraints

None.

Examples

{
"amt": 0,
"aur": "T",
"ba": {
"street": "",
"city": "",
"state": "al",
"country": "US",
"zip": ""
},

Given an array of non-negative integers representing terraces in an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.

Examples

Example #1

Input: arr[] = [2, 0, 2]
Output: 2

Zeros to End of Array

Given an array of random numbers, write a function:

function pushZerosToEnd(array){
    return arrayWithZeros
}

Target Value

Given two arrays a and b and target value t, write a function that returns the two values from each array that add up to the target t.

Ex:

const a = [3, 5, 7, 8]
const b = [3, 5, 1, 9]
const t = 12
pragma solidity ^0.4.21;
/**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/
contract Ownable {
address public owner;
@NFhbar
NFhbar / Ballot.sol
Created May 20, 2018 18:26
Example Gist for Contract Verification.
pragma solidity ^0.4.21;
contract Ballot {
struct Voter {
uint weight;
bool voted;
uint8 vote;
address delegate;
}
const Faucet = artifacts.require('Faucet')
const token = artifacts.require('AvocadoToken')
import utils from '../helpers/utils'
import assertRevert from '../helpers/assertRevert'
import { increaseTimeTo, duration } from '../helpers/increaseTime'
import latestTime from '../helpers/latestTime'
contract('Faucet Contract - drips 1000 Token', accounts => {
// variables
let faucet
@NFhbar
NFhbar / Faucet.sol
Created May 15, 2018 19:52
Avocado Network Faucet Contract v2.0.0
pragma solidity ^0.4.23;
/**
* @title ERC20Basic
* @dev Simpler version of ERC20 interface
* @dev see https://github.com/ethereum/EIPs/issues/179
*/
contract ERC20Basic {
function totalSupply() public view returns (uint256);
function balanceOf(address who) public view returns (uint256);