-
Notifications
You must be signed in to change notification settings - Fork 1
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
bravacoreana
wants to merge
1
commit into
main
Choose a base branch
from
liha-210608
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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; | ||
} | ||
if (sum > max) max = sum; | ||
}); | ||
return max; | ||
}; |
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
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 ith customer has in the jth 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) {}; | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
var isSumEqual = function (firstWord, secondWord, targetWord) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. constraint를 보면 알파벳이 a to j까지 되어 있는데 그 부분을 없는 것 같네요~! a,b,c 만 생각하신 것 같습니다. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
}; |
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
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) {}; | ||
``` |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기도 마찬가지로
forEach
로 사용해도 괜찮을 듯 합니다.