function sort012(arr, N) { let one=0; let zero=0; let two =0; for(let i=0; i<N; i++){ if(arr[i]==0){ zero++; }else if(arr[i]==1){ one++; }else{ two++; } } for(let k=0; k<N; k++){ if(zero !=0){ arr[k]=0; zero-- }else if(one !=0){ arr[k]=1; one-- }else if(two !=0){ ...
/** * @param {number[]} nums * @return {number} */ var maxSumOfSubArray = function(nums) { let localMax =0; let GlobalMax = Number.NEGATIVE_INFINITY; for(let i=0; i<nums.length; i++){ localMax = localMax+ nums[i]; GlobalMax = Math.max(localMax, GlobalMax); if(localMax <0){ localMax =0; } } return ...
In this post we will create a tool for coloring cells of a table. <div id="menuitems"> <h2 >Coloring Table<span id="timer"></span></h2> <button id="colorTable" class="btn btn-outline-dark btn-sm" data-bs-toggle="button" autocomplete="off" onclick="setColorPicker()"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-paint-bucket" viewBox="0 0 16 16"> <path ...