Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[liha-210608] | 1672 | 1880 | #38

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions bravacoreana/1672/1672.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
var maximumWealth = function (accounts) {
let max = 0;
accounts.forEach((account) => {
let sum = 0;
for (a of account) {
sum += a;
}
Comment on lines +5 to +7
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기도 마찬가지로 forEach로 사용해도 괜찮을 듯 합니다.

if (sum > max) max = sum;
});
return max;
};
50 changes: 50 additions & 0 deletions bravacoreana/1672/README.md
Original file line number Diff line number Diff line change
@@ -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) {};
```
16 changes: 16 additions & 0 deletions bravacoreana/1880/1880.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
var isSumEqual = function (firstWord, secondWord, targetWord) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

constraint를 보면 알파벳이 a to j까지 되어 있는데 그 부분을 없는 것 같네요~! a,b,c 만 생각하신 것 같습니다.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

헉 그러네여! 다시 풀어볼겠습니당!

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;
};
60 changes: 60 additions & 0 deletions bravacoreana/1880/README.md
Original file line number Diff line number Diff line change
@@ -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) {};
```