Loading...
More JavaScript Posts
const bucketSort = (arr, size = 5) => {const min = Math.min(...arr);const max = Math.max(...arr);const buckets = Array.from({ length: Math.floor((max - min) / size) + 1 },() => []);arr.forEach(val => {buckets[Math.floor((val - min) / size)].push(val);});return buckets.reduce((acc, b) => [...acc, ...b.sort((a, b) => a - b)], []);};bucketSort([6, 3, 4, 1]); // [1, 3, 4, 6]
function Welcome(props) {return <h1>Hello, {props.name}</h1>;}function App() {return (<div><Welcome name="Sara" /><Welcome name="Cahal" /><Welcome name="Edite" /></div>);}ReactDOM.render(<App />,document.getElementById('root'));
// Time Complexity : O(N)// Space Complexity : O(1)var isMonotonic = function(nums) {let isMono = null;for(let i = 1; i < nums.length; i++) {if(isMono === null) {if(nums[i - 1] < nums[i]) isMono = 0;else if(nums[i - 1] > nums[i]) isMono = 1;continue;}if(nums[i - 1] < nums[i] && isMono !== 0) {return false;}else if(nums[i - 1] > nums[i] && isMono !== 1) {return false;}}return true;};let nums1 = [1,2,2,3]let nums2 = [6,5,4,4]let nums3 = [1,3,2]console.log(isMonotonic(nums1));console.log(isMonotonic(nums2));console.log(isMonotonic(nums3));
function printHeap(heap, index, level) {if (index >= heap.length) {return;}console.log(" ".repeat(level) + heap[index]);printHeap(heap, 2 * index + 1, level + 1);printHeap(heap, 2 * index + 2, level + 1);}//You can call this function by passing in the heap array and the index of the root node, which is typically 0, and level = 0.let heap = [3, 8, 7, 15, 17, 30, 35, 2, 4, 5, 9];printHeap(heap,0,0)
//use this with canvas file finderfunction NewTab(testing) {window.open(testing, "_blank");}for(test in results) {var testing = 'https://unt.instructure.com/files/' + test + '/download';NewTab(testing);}
results ={"11345240":"Media Comment-80e47004-1719-493a-af69-a43b2652b41c","11345282":"zoom_3_22_21.mp4","11345303":"Recording-2.m4a","11345348":"February 12%2C 2021.mp4","11345826":"Lecture_Rousso_Chapter_06-2.pptx","11345933":"Themes_InClassAssigment.pptx","11346193":"Agenda – Week of March23.pptx","11346318":"MUJS 2370 SP2021 Updated Rhythm Changes Drills Bb - Score.pdf","11346319":"MUJS 2370 SP2021 Updated Rhythm Changes Drills C - Score.pdf","11346322":"MUJS 2370 SP2021 Updated Rhythm Changes Drills Eb - Score.pdf","11346323":"MUJS 2370 Updated Rhythm Changes Drills Bass - Score.pdf","11346381":"Anthropology with colored highlighter analysis - Mar 22 2021 - 10-36 AM.pdf","11346449":"Anthropology with colored highlighter analysis - Mar 22 2021 - 10-36 AM.pdf","11346450":"MUJS 2370 SP2021 Updated Rhythm Changes Drills Bb - Score.pdf","11346451":"MUJS 2370 SP2021 Updated Rhythm Changes Drills C - Score.pdf","11346453":"MUJS 2370 SP2021 Updated Rhythm Changes Drills Eb - Score.pdf","11346454":"MUJS 2370 Updated Rhythm Changes Drills Bass - Score.pdf","11346495":"Steinel chromatic ornamentation étude rhythm changes - Aug 23 2020 - 12-19 PM.pdf","11346532":"Media Comment-136242b4-7f2c-4d5d-8aa4-091f07e797cf","11346581":"2019 Trust Based Relationship Intervention Manual.pdf","11346584":"TBRI ppt.pptx","11346593":"Trauma informed care.ppt"}function NewTab(testing) {window.open(testing, "_blank");}for(test in results) {var testing = 'https://unt.instructure.com/files/' + test + '/download';NewTab(testing);//window.open = 'https://unt.instructure.com/files/' + test + '/download';}