I was trying to approach this problem by splitting half. For example,

set the mid “4” and then split left and right. Define these like left = [1,2], right=[2,1] and mid=4. So all i have to do is right.reverse() to compare with left part. if(left === right.reverse()) should return “YES” else it’s not!

If the each row’s length is even number,

For example, if the length is 6, the left and right length should be 3.

My rubbish code :)

Summary

  • Giveaway free crypto is the future of corporation’s marketing rewards
  • Experience compounding interest on Binance platform
  • Fundraise from crypto to invest in great stocks such as Alphabet($GOOG), Berkshire Hathaway($BRK/B) and The Estée Lauder Companies($EL)
  • Stock dividend will help to boost the return
  • Remember this equation. 3rd party mining apps +…

Here’s how I got involved in crypto world. I am actually stock investor and do not trust in crypto value like other investors. Nowadays, people buy a Tesla with Bitcoin. So i was thinking like i’m a software developer so why not buy the new Macbook 2021 model for myself?

Collecting crypto assets

First STEEM…

At the first time, i used nested for loop. so the worst case of time complexity is O(n²).

This is a brute-force example.

Pseudocode

// [2,7,11,15]
// for looop nums[i] === 2
// another for loop
// for { [0]
// for { // [1]
// if(nums[i] + nums[j] === target) {
// return [i, j]
// }
// }
// }

The worst case of time complexity is O(n²).
If we want to do it in a better PS, we could do with hash map.

Hash map is key-value structure.

Pseudocode

// sort nums arr in order
// [2,3,4];
// nums[i] + num[i+1] === target and then do arr.shift()
// return arr
// else

Final answer

JavaScript has search methods for arrays.

  • indexOf
  • includes
  • find
  • findIndex

Linear search

Loop through the array and check if there’s a matched element, return the index. If there’s not, just simply return -1

  1. useState

we don’t really define the types in useState.
import useState from react

whatever we put the initial value, we have to stick to it. For example, the above example is defined with boolean type. Now we can inform TS that the type of User can be null or AuthUser.

2. useReducer

iDevBrandon

Investor & Software Developer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store