-
Notifications
You must be signed in to change notification settings - Fork 46
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
1512. Number of Good Pairs #74
Labels
Comments
Merged
又來麻煩大大,尋求命名建議了 orz public int IdenticalPairsCount(int[] inputNumbers)
{
int numberOfIdenticalPairs = 0;
for (int index = 0; index < inputNumbers.Length-1; ++index)
{
for (int nextIndex = index+1; nextIndex< inputNumbers.Length; ++nextIndex)
{
if (inputNumbers[index] == inputNumbers[nextIndex] )
{
++numberOfIdenticalPairs;
}
}
}
return numberOfIdenticalPairs;
} |
堅持「刻意練習」,一定會進步的 💪 int numberOfIdenticalPairs = 0; 這個命名很好懂 👍 另外可能的寫法有 for (int index = 0; index < inputNumbers.Length-1; ++index)
{
for (int nextIndex = index+1; nextIndex< inputNumbers.Length; ++nextIndex) 這個地方,或許可以用 我的想法是:
不過,當作練習,如果我們就是不想要用 我想我會沿用 LeetCode 題目中的用詞 "good pair", 然後寫成
或
🤔 |
@twy30 感謝大大的鼓勵和指教 orz |
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://leetcode.com/problems/number-of-good-pairs/
請參考「刷 LeetCode 練習命名」 #69 😊
The text was updated successfully, but these errors were encountered: