Giter Site home page Giter Site logo

take-home-test's Introduction

NOTES

The solutions are wtih file name question-1.js, question-2.js and question-3.js

Question#1

This solution O(2n) with n is record's length.

Question#2

  1. This solution O(n) with n is total users while get totalPlayerByStages.
  2. This solution O(n) with n is total stages (N) while get failureRateByStages.
  3. This solution O(n) with n is total stages (N) while map list of stages.
  4. I don't know time complexity for sort function

Question#3

  1. Maybe for this case I think more efficient with looping, with lopping 'easier' to cache / memoize, but I think it will hard to naming and validate the rule, so for this solution I separate unique column and non unique column.
  2. After separate change non unique column to unique column with combine / join value for each two column, with minimality rule, I think / intepret it just needs two key to candidates key, e.g:
[
    [
      'COL#2 - COL#3',
      'ryan - music',
      'apeach - math',
      'tube - computer',
      'con - computer',
      'muzi - music',
      'apeach - music'
    ],
    [
      'COL#2 - COL#4',
      'ryan - 2',
      'apeach - 2',
      'tube - 3',
      'con - 4',
      'muzi - 3',
      'apeach - 2'
    ],
    ...
]
  1. Using this new column list / matrix we just need check unique column.
  2. This solution O(n) with n is total rows, when to get list of value by column, for each array I set COL#i with i is index column started 1 to columns length, I need this as array to simplify the process instead of as object with column inex as key / property.
  3. Then O(n) with n is total columns, when separate uniqueColumnNames and nonUniqueColumns.
  4. Then O(n!) with n is total non unique column, when get joined columns to make easier check unique or not.
  5. Then O(n) with n is total joined columns, when get unique columns to get relation keys for candidate besides column name from unique keys that get in step 2, because I use the function that same in step-2 I sacriface space complexity because actually we didn't need non uniques columns in step-5
  6. Actually because I want to make it same with example, although that needed is just total cadidate key, and I wanted to simplify filter and map by using reduce, the code is not sweet as before, you can jump to https://github.com/detikpw/take-home-test/commit/80437c059207c517cbee69cb1e24bacdc4c5a574

Extra

  1. Already tested using Firefox 85.0.2 (64-bit) and google chrome Version 76.0.3809.100 (Official Build) (64-bit), for node js minimum version is 12
  2. Just ignore generator js, It just needed to make dummy records and relation for question#1 and qustion#3 with break some limitation in each question, and I want to test faker js and snapshot test

take-home-test's People

Contributors

detikpw avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.