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
while (itemIdx < item.size()) { | |
Map itm = (Map)(item.get(itemIdx)); | |
//ensure both itm and nextItem contain externalId - i.e the NS product mapping | |
if (itm.containsKey("item") && itm["item"].containsKey("externalId") && | |
nextItem.containsKey("item") && nextItem["item"].containsKey("externalId")) { | |
//find which invoice item nextItem should be applied to | |
appliedToItemId = record.get("InvoiceItem.AppliedToInvoiceItemId"); | |
//System.out.println("Itm ext id:" + itm["item"]["externalId"] + ", Applied to Id:" + appliedToItemId); | |
//if ((itm["item"]["externalId"] != null) && itm["item"]["externalId"].equals(appliedToItemId)) { | |
//add amount to existing |
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
while (itemIdx < item.size()) { | |
Map itm = (Map)(item.get(itemIdx)); | |
//ensure both itm and nextItem contain externalId - i.e the NS product mapping | |
if (itm.containsKey("item") && itm["item"].containsKey("externalId") && | |
nextItem.containsKey("item") && nextItem["item"].containsKey("externalId")) { | |
//find which invoice item nextItem should be applied to | |
appliedToItemId = record.get("InvoiceItem.AppliedToInvoiceItemId"); | |
//System.out.println("Itm ext id:" + itm["item"]["externalId"] + ", Applied to Id:" + appliedToItemId); | |
//if ((itm["item"]["externalId"] != null) && itm["item"]["externalId"].equals(appliedToItemId)) { | |
//add amount to existing |
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
import java.io.*; | |
import java.util.*; | |
/* | |
*/ | |
class Solution { | |
// Implement me! | |
static String int2String(int n) { | |
if (n == 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
public static void int2String(int n) { | |
return Integer.toString(n); | |
} | |
public static void int2String(int n) { | |
return "" + n; | |
} |
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
public static String int2String(int n) { | |
int power = 0; | |
int nCopy = n; | |
while (nCopy > 0) { | |
power++; | |
nCopy = nCopy / 10; | |
} | |
// 10^power is one order higher than what we want. | |
power--; |
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
public static String int2String(int n) { | |
while (n > 0) { | |
int digit = n % 10; | |
n = n / 10; | |
} | |
// To be implemented... | |
} |
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
public static String int2String(int n) { | |
List<String> digits = new ArrayList<>(); | |
while (n > 0) { | |
int digit = n % 10; | |
digits.add(digit2String(digit)); | |
n = n / 10; | |
} | |
// To be implemented... |
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
// Approach 1: if/else chain. (This could also be a switch.) | |
public static String digit2String(int digit) { | |
if (digit == 0) { | |
return "0"; | |
} else if (digit == 1) { | |
return "1"; | |
} else if (digit == 2) { | |
return "2"; | |
} else if (digit == 3) { | |
return "3"; |
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
public static String int2String(int n) { | |
List<String> digits = new ArrayList<>(); | |
while (n > 0) { | |
int digit = n % 10; | |
digits.add(digit2String(digit)); | |
n = n / 10; | |
} | |
String 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
public static String int2String(int n) { | |
if (n == 0) { | |
return "0"; | |
} | |
List<String> digits = new ArrayList<>(); | |
while (n > 0) { | |
int digit = n % 10; | |
digits.add(digit2String(digit)); |
OlderNewer