diff --git a/bravacoreana/1672/1672.js b/bravacoreana/1672/1672.js new file mode 100644 index 0000000..a4d8480 --- /dev/null +++ b/bravacoreana/1672/1672.js @@ -0,0 +1,11 @@ +var maximumWealth = function (accounts) { + let max = 0; + accounts.forEach((account) => { + let sum = 0; + for (a of account) { + sum += a; + } + if (sum > max) max = sum; + }); + return max; +}; diff --git a/bravacoreana/1672/README.md b/bravacoreana/1672/README.md new file mode 100644 index 0000000..6e60ee2 --- /dev/null +++ b/bravacoreana/1672/README.md @@ -0,0 +1,50 @@ +# 1672. Richest Customer Wealth + +You are given an m x n integer grid accounts where accounts[i][j] is the amount of money the i​​​​​​​​​​​th​​​​ customer has in the j​​​​​​​​​​​th​​​​ bank. + +Return the wealth that the richest customer has. + +A customer's wealth is the amount of money they have in all their bank accounts. The richest customer is the customer that has the maximum wealth. + +``` +- Example 1: +Input: accounts = [[1,2,3],[3,2,1]] +Output: 6 +Explanation: +1st customer has wealth = 1 + 2 + 3 = 6 +2nd customer has wealth = 3 + 2 + 1 = 6 +Both customers are considered the richest with a wealth of 6 each, so return 6. + + +- Example 2: +Input: accounts = [[1,5],[7,3],[3,5]] +Output: 10 +Explanation: +1st customer has wealth = 6 +2nd customer has wealth = 10 +3rd customer has wealth = 8 +The 2nd customer is the richest with a wealth of 10. + +- Example 3: +Input: accounts = [[2,8,7],[7,1,3],[1,9,5]] +Output: 17 +``` + +## Constraints: + +``` +m == accounts.length +n == accounts[i].length +1 <= m, n <= 50 +1 <= accounts[i][j] <= 100 +``` + +## Code: + +```js +/** + * @param {number[][]} accounts + * @return {number} + */ +var maximumWealth = function (accounts) {}; +``` diff --git a/bravacoreana/1880/1880.js b/bravacoreana/1880/1880.js new file mode 100644 index 0000000..7b49923 --- /dev/null +++ b/bravacoreana/1880/1880.js @@ -0,0 +1,16 @@ +var isSumEqual = function (firstWord, secondWord, targetWord) { + let testValue = [firstWord, secondWord, targetWord]; + for (let i = 0; i < testValue.length; i++) { + let newWord = "0"; + testValue[i].split("").forEach((alphabet) => { + if (alphabet === "a") newWord += "0"; + if (alphabet === "b") newWord += "1"; + if (alphabet === "c") newWord += "2"; + }); + testValue[i] = newWord; + } + + return parseInt(testValue[0]) + parseInt(testValue[1]) == testValue[2] + ? true + : false; +}; diff --git a/bravacoreana/1880/README.md b/bravacoreana/1880/README.md new file mode 100644 index 0000000..fb607e8 --- /dev/null +++ b/bravacoreana/1880/README.md @@ -0,0 +1,60 @@ +# 1880. Check if Word Equals Summation of Two Words + +The letter value of a letter is its position in the alphabet starting from 0 (i.e. `'a' -> 0`, `'b' -> 1`, `'c' -> 2`, etc.). + +The numerical value of some string of lowercase English letters `s` is the concatenation of the letter values of each letter in `s`, which is then converted into an integer. + +For example, if `s = "acb"`, we concatenate each letter's letter value, resulting in `"021"`. After converting it, we get `21`. +You are given three strings `firstWord`, `secondWord`, and `targetWord`, each consisting of lowercase English letters `'a'` through `'j'` inclusive. + +Return `true` _if the summation of the numerical values of_ `firstWord` and `secondWord` equals the numerical value of `targetWord`, or `false` otherwise. + +``` +- Example 1: +Input: firstWord = "acb", secondWord = "cba", targetWord = "cdb" +Output: true +Explanation: +The numerical value of firstWord is "acb" -> "021" -> 21. +The numerical value of secondWord is "cba" -> "210" -> 210. +The numerical value of targetWord is "cdb" -> "231" -> 231. +We return true because 21 + 210 == 231. + + +- Example 2: +Input: firstWord = "aaa", secondWord = "a", targetWord = "aab" +Output: false +Explanation: +The numerical value of firstWord is "aaa" -> "000" -> 0. +The numerical value of secondWord is "a" -> "0" -> 0. +The numerical value of targetWord is "aab" -> "001" -> 1. +We return false because 0 + 0 != 1. + + +- Example 3: +Input: firstWord = "aaa", secondWord = "a", targetWord = "aaaa" +Output: true +Explanation: +The numerical value of firstWord is "aaa" -> "000" -> 0. +The numerical value of secondWord is "a" -> "0" -> 0. +The numerical value of targetWord is "aaaa" -> "0000" -> 0. +We return true because 0 + 0 == 0. +``` + +## Constraints: + +``` +- 1 <= firstWord.length, secondWord.length, targetWord.length <= 8 +- firstWord, secondWord, and targetWord consist of lowercase English letters from 'a' to 'j' inclusive. +``` + +## Code: + +```js +/** + * @param {string} firstWord + * @param {string} secondWord + * @param {string} targetWord + * @return {boolean} + */ +var isSumEqual = function (firstWord, secondWord, targetWord) {}; +```