Skip to content

Instantly share code, notes, and snippets.

View alex-r89's full-sized avatar

Alex alex-r89

  • London
View GitHub Profile
@alex-r89
alex-r89 / with-apollo.js
Created July 5, 2021 12:46
Apollo Client
import * as React from 'react'
import { ApolloProvider } from '@apollo/client'
import { initApolloClient } from './apollo-client'
/*
This wrapper helps to provide Apollo functionality during SSR, while rehydrating
on the client with a pre-populated cache of the query results.
Refer to https://github.com/zeit/next.js/blob/canary/examples/api-routes-apollo-server-and-client/apollo/client.js
for more source.
@alex-r89
alex-r89 / solutions.md
Last active January 31, 2021 18:20
Hackerrank Solutions in JavaScript

Hackerrank Solutions

Easy

Array Matrix (Diagonal Difference)

Given a square matrix, calculate the absolute difference between the sums of its diagonals.

function diagonalDifference(arr) {
  // arr eg: [ [ 11, 2, 4 ], [ 4, 5, 6 ], [ 10, 8, -12 ] ]
    
    const arrLength = arr.length