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
int countLayers(List<String> matrix) { | |
int horiCenter = matrix[1].length ~/ 2; | |
int vertCenter = matrix.length ~/ 2; | |
print("$vertCenter hori $horiCenter"); | |
int layerCount = 0; | |
for (int i = 0; i <= vertCenter; i++) { | |
if (i == 0) { | |
layerCount++; | |
continue; |
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
int maxCollinear(List<List<int>> points) { | |
List<int> collinearPoins = []; | |
for (int i = 0; i < points.length - 1; i++) { | |
int counter = 0; | |
for (int j = 0; j < points.length; j++) { | |
if (j != i && j != (i + 1)) { | |
if (arePointsCollinear(points[i], points[i + 1], points[j])) { | |
counter++; | |
} | |
} |
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
List<List<dynamic>> updateInventory( | |
List<List<dynamic>> inventoryOne, List<List<dynamic>> inventoryTwo) { | |
Map<String, int> inventoryMap = {}; | |
inventoryOne.forEach((List item) { | |
inventoryMap[item[1]] = item[0]; | |
}); | |
inventoryTwo.forEach((List item) { | |
if (inventoryMap.containsKey(item[1])) { | |
inventoryMap[item[1]] += item[0]; | |
} else { |
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 sortingList = function(list){ | |
let j = 0; | |
for(var i = 0;i<list.length;i++){ | |
var max_of_array = Math.max.apply(Math, list.slice(j,list.length)); | |
list[j]=max_of_array | |
var index = list.indexOf(max_of_array) | |
list.splice(index,1) | |
j++ | |
} | |
} |
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 sortingList = function(list){ | |
for(var i = 0;i<list.length;i++){ | |
var max_of_array = Math.min.apply(Math, list.slice(i,list.length)); | |
var index = list.indexOf(max_of_array) | |
list[index] = list[i] | |
list[i] = max_of_array | |
} | |
console.log(list) | |
} | |
sortingList([2,3,1,4,8]) |
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
void addToList(List<dynamic> numbers, List<List<dynamic>> temp) { | |
List<dynamic> tempo = []; | |
numbers.forEach((integer) { | |
tempo.add(integer); | |
}); | |
temp.add(tempo); | |
} | |
void swap(List<dynamic> list, int i, int j) { | |
dynamic temp = list[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
const axios = require('axios'); | |
async function getTotalPriceInBaseCurrency(prices, baseCurrency, date) { | |
prices = prices.replace(/\$/gm, 'USD').replace(/€/gm, 'EUR').replace(/₹/gm, 'INR').replace('£', 'GBP').replace(/,/gm, ''); | |
let itemList = {}; | |
prices.replace(/(([A-Z]{3}) {0,}([\d*\.{0,1}\d*,]*))/gm, (m, g1, g2, g3) => { | |
if (itemList[g2]!==undefined) { | |
itemList[g2] += Number(g3) | |
} else { | |
itemList[g2] = Number(g3); |
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
function treeToArray(tree) { | |
let result = [tree['value']]; | |
let pointer = 0; | |
while (pointer < result.length) { | |
if (result[pointer] !== null) { | |
while (result[result.length - 1] === null) { | |
result.pop() | |
} | |
let children = findNode(tree, result[pointer]); |
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
function taskScheduler(tasks = [], n = 1) { | |
let charMap = {}; | |
tasks.forEach((task) => { | |
if (charMap[task] !== undefined) { | |
charMap[task] += 1 | |
} else { | |
charMap[task] = 1; | |
} | |
}); |
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
function taskScheduler(tasks = [], n = 1) { | |
let charMap = {}; | |
tasks.forEach((task) => { | |
if (charMap[task] !== undefined) { | |
charMap[task] += 1 | |
} else { | |
charMap[task] = 1; | |
} | |
}); |
OlderNewer