This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Given an array of random characters with size n, | |
// String[] stringArr = ["A", "C", "K", "B" .....]; | |
// write a procedure that will scan the array from the first element | |
// and print the first character that appear three times during scanning | |
const TOTAL_APPEAR = 3; | |
function scanArray(data) { | |
let flag = 0; | |
const result = [] | |
const dataLength = data.length; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// switchWordByIndex | |
// return new string switched by index | |
const switchWordByIndex = (words, index, wordSwitched) => (words.substr(0, index) + wordSwitched + words.substr(index + 1)); | |
// swapWordBasedOnIndex | |
// return new string swaped | |
const swapStringBasedOnIndex = (words, indexWord, indexComparedWord) => { | |
// switch first word as temporary words | |
const switchFirstWord = switchWordByIndex(words, indexWord, words[indexComparedWord]); | |
// switch second word and get the result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let solution = (relation) => { | |
let answer = 0; | |
let dataRow = []; | |
let findDuplicates = (arr) => | |
arr.filter((item, index) => arr.indexOf(item) != index); | |
// - Uniqueness: The relation does not have two distinct tuples | |
// (i.e. rows or records in common database language) | |
// with the same values for these attributes. | |
for (let i = 0; i < relation[0].length; i++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let solution = (n, users) => { | |
let answer = []; | |
let totalUsers = users.length; | |
let countDuplicateStageUsers = users.reduce((prev, curr) => { | |
prev[curr] = (prev[curr] || 0) + 1; | |
return prev; | |
}, {}); | |
// looping stages | |
for (let i = 1; i <= n; i++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let solution = (record) => { | |
let answer = []; | |
let userChat = []; | |
for (let i = 0; i < record.length; i++) { | |
let command = record[i].split(" ")[0]; | |
let userId = record[i].split(" ")[1]; | |
let nickName = record[i].split(" ")[2]; | |
let checkExistingUser = userChat | |
.map((data, index) => (data.userId === userId ? index : "")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"lastUpload":"2019-01-22T04:16:46.206Z","extensionVersion":"v3.2.4"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fractions = [100000, 50000, 20000, 10000, 5000, 1000, 500, 100, 50]; | |
var result = []; | |
var noFractionValue; | |
function doCheckNoFraction(input) { | |
return input < fractions[fractions.length-1] | |
} | |
function doCalculate(input) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var result = []; | |
var count = 0; | |
var resultCount = []; | |
function longestBinaryGap(decimal) { | |
var divide = decimal / 2; | |
var divideRound = Math.floor(divide); | |
if (decimal % 2 != 0) { | |
count = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var result = []; | |
var count = 0; | |
var resultCount = []; | |
function decimalToBinary(decimal) { | |
var divide = decimal / 2; | |
var divideRound = Math.floor(divide); | |
decimal % 2 != 0 ? result.push(1) : result.push(0); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
webpackJsonp([1,2],{109:function(e,t,a){"use strict";function n(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments[1];for(var a in t)void 0===e[a]&&(e[a]=t[a]);return e}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n,e.exports=t.default},115:function(e,t,a){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function l(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var |
NewerOlder