This file contains hidden or 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 knapsack01(maxWeight, items, returnAllKnapsacks) { | |
items = items.sort((a,b)=>a.weight-b.weight); | |
var knapsacks = new Array(maxWeight + 1); | |
for (var i = 0; i <= maxWeight; i++) { | |
knapsacks[i] = new Array(items.length); | |
for (var j = 0; j < items.length; j++) { | |
knapsacks[i][j] = 0; | |
}; | |
}; |
This file contains hidden or 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 betterMinNumOfCoins(coinages, amount) { | |
// sort coinages | |
coinages = coinages.sort((a,b)=>a-b); | |
var minCoinage = Math.min.apply(null, coinages); | |
var dp = new Array(amount + 1).fill(Infinity); | |
dp[0] = 0; | |
for (var i = 1; i <= amount; i++) { | |
for (var j = 0; j < coinages.length; j++) { | |
var coinage = coinages[j]; | |
if (coinage > i) break; |
This file contains hidden or 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 minNumOfCoins(coinages, amount) { | |
if (amount === 0) return 0; | |
if (coinages.length === 0 && amount > 0) return Infinity; | |
var maxCoinage = Math.max.apply(null, coinages); | |
var otherCoinages = coinages.filter(coinage => coinage !== maxCoinage) | |
if (amount < maxCoinage) return minNumOfCoins(otherCoinages, amount); | |
var coinsWithMaxCoinage = minNumOfCoins(coinages, amount - maxCoinage) + 1; | |
var coinsWithoutMaxCoinage = minNumOfCoins(otherCoinages, amount); |
This file contains hidden or 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 boardsBinarySearch(A, numBoards) { | |
var n = A.length; | |
var minBoardSize = 1; | |
var maxBoardSize = n; | |
var result = -1; | |
while (minBoardSize <= maxBoardSize) { | |
var tentativeBoardSize = Math.floor((minBoardSize + maxBoardSize) / 2); | |
if (neededBoards(A, tentativeBoardSize) <= numBoards) { | |
result = tentativeBoardSize; | |
maxBoardSize = tentativeBoardSize - 1; |
This file contains hidden or 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 solution(A,B,C) { | |
return nailsBinarySearch(A,B,C); | |
} | |
function nailsBinarySearch(boardStarts, boardEnds, nailPositions) { | |
var boards = boardStarts.map((cur, curIndex) => [cur, boardEnds[curIndex]],[]); | |
var lowerBorderNailsNumber = 1; | |
var upperBorderNailsNumber = nailPositions.length; | |
var minimalNailsNumber = -1; |
This file contains hidden or 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 solution(K, M, A) { | |
// M is a red herring | |
return minimalLargeSumBinarySearch(K, A); | |
} | |
function minimalLargeSumBinarySearch(maxNumBlocks, arra) { | |
var lowerBoundLargeSum = Math.max.apply(null, arra); | |
var upperBoundLargeSum = arra.reduce((a,c)=>a+c,0); | |
var result = -1; | |
This file contains hidden or 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
package com.wcg.product.ajax.ajaxserver.connectors; | |
import java.net.URL; | |
import org.apache.commons.lang.StringUtils; | |
import org.eclipse.jetty.server.Server; | |
import org.eclipse.jetty.xml.XmlConfiguration; | |
public class StandaloneServer { |
This file contains hidden or 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
- right-click project with issue | |
- maven --> update project | |
- de-select "clean projects" at the bottom | |
- OK |
This file contains hidden or 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
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<parent> | |
<groupId>com.xxx.yyy</groupId> | |
<artifactId>XXXX</artifactId> | |
<version>1.2.0-SNAPSHOT</version> | |
</parent> | |
<groupId>xxx.yyy.migration</groupId> | |
<artifactId>YYY</artifactId> |