Given the following array, [6, 2, 3, 8]
find the minimum number of entries needed to make the array consecutive
[2, 3, *4*, *5*, 6, *7*, 8]
= 3 entries needed.
Test cases
makeConsecutive([0, 2]) === 2
import Component from './toy-react' | |
import { div, img } from './toy-jsx' | |
class Nested extends Component { | |
render () { | |
const { src, style } = this.props; | |
return img({ src, style }) | |
} | |
} |
import React from 'react'; | |
import useStore from './useStore'; | |
import Todo from './Todo' | |
import { todoActions } from './actions'; | |
export default () => { | |
const [ | |
todos, | |
{ addTodo, rmTodo } | |
] = useStore(store => store.todos, todoActions) |
import React, { | |
createContext, | |
useContext, | |
useState, | |
FC, | |
Dispatch, | |
SetStateAction, | |
} from "react"; | |
import Counter from "../Components/Counter"; |
import React from 'react'; | |
import { atom, selector, useRecoilValue, useSetRecoilState } from 'recoil'; | |
import Counter from '../Components/Counter' | |
const counterState = atom({ | |
key: 'counter', | |
default: 0 | |
}); |
import React from 'react'; | |
import { hawk, hawkeye, useHawkState, useHawkSetState } from 'react-hawk'; | |
import Counter from '../Components/Counter' | |
const counterState = hawk({ | |
key: 'counter', | |
default: 0 | |
}); |
import gql from 'graphql-tag' | |
export const mountainSchema = gql` | |
type Mountain @collection(name: "mountains", crud: true) { | |
id: ObjectId | |
name: String @insert @set @filter | |
meters: Float @insert @set @filter | |
feet: Float @insert @set @filter | |
location: String @insert @set @filter | |
} |
{ | |
"schema": ["./node_modules/ts-mongo-codegen/dist/types/mongo-types.ts", "./src/gql/*.ts"], | |
"generates": { | |
"./src/types.generated.ts": { | |
"plugins": [ | |
"typescript", | |
"typescript-operations", | |
"typescript-resolvers", | |
"ts-mongo-codegen" | |
] |
import { makeExecutableSchema } from '@graphql-tools/schema' | |
import { addResolveFunctionsToSchema } from 'apollo-server' | |
import { graphqlTypeDate, graphqlTypeObjectId, makeAugmentedSchema, mongoTypeDefs } from 'ts-mongo-codegen' | |
// The following import is the file generated in previous step | |
import { mountainMutationResolvers, mountainQueryResolvers, mountainResolvers } from './types.generated' | |
import { composeResolvers } from '@graphql-tools/resolvers-composition' | |
import { mountainSchema } from './gql/mountains' | |
import { isAuthenticated } from './auth' | |
// Make an executable schema with the mongo types and our custom mountain schema type |
const nodeApi = "https://nodeapi.energi.network/"; | |
const owner = "YOUR_MASTERNODE_OWNER_ADDRESS" | |
estimateBlocksTilNextMasternodeReward(owner) | |
.then(({ estimatedTimestamp }) => console.log(`Next reward at ${new Date(estimatedTimestamp).toLocaleString()}`)) | |
function listMasternodes () { | |
return rpc(nodeApi, "masternode_listMasternodes"); | |
} |