문제 출처:https://leetcode.com/problems/height-checker
Height Checker - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com

코드는 다음과 같습니다:
class Solution {
public:
int heightChecker(vector<int>& heights) {
int answer = 0 ;
vector<int> sorted_heughts(heights) ;
sort(sorted_heughts.begin(), sorted_heughts.end()) ;
for(int i = 0 ; i < heights.size() ; i++)
if(heights[i] != sorted_heughts[i])
answer += 1;
return answer ;
}
};
해당 문제는 Github에서도 보실 수 있습니다:
https://github.com/gurcks8989/CodingTest/blob/master/LeetCode/P1051_Height_Checker.cpp
GitHub - gurcks8989/CodingTest: CodingTest_study_with_c++
CodingTest_study_with_c++. Contribute to gurcks8989/CodingTest development by creating an account on GitHub.
github.com
훈수 및 조언은 언제든 환영입니다.
문제 출처:https://leetcode.com/problems/height-checker
Height Checker - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com

코드는 다음과 같습니다:
class Solution {
public:
int heightChecker(vector<int>& heights) {
int answer = 0 ;
vector<int> sorted_heughts(heights) ;
sort(sorted_heughts.begin(), sorted_heughts.end()) ;
for(int i = 0 ; i < heights.size() ; i++)
if(heights[i] != sorted_heughts[i])
answer += 1;
return answer ;
}
};
해당 문제는 Github에서도 보실 수 있습니다:
https://github.com/gurcks8989/CodingTest/blob/master/LeetCode/P1051_Height_Checker.cpp
GitHub - gurcks8989/CodingTest: CodingTest_study_with_c++
CodingTest_study_with_c++. Contribute to gurcks8989/CodingTest development by creating an account on GitHub.
github.com
훈수 및 조언은 언제든 환영입니다.