릿코드12 19★] Leetcode 1436. Destination City 최종 목적지를 반환하는 문제. Destination City - 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 양 끝점만 한번 나오고 나머지 city는 두 번씩 나오니까 한 번만 나오는 city 중에 목적지에 있는 city를 반환하는 문제. class Solution { public: string destCity(vector& paths) { // 한번나오고 뒤에 배치되어있는 문자열 반환 map words; map::iterator it; for(int i = .. 2020. 6. 30. 18] Leetcode 1475. Final Prices With a Special Discount in a Shop Final Prices With a Special Discount in a Shop - 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 숫자 배열을 for문 돌면서 다음 숫자부터 마지막까지 숫자들 중에 for문의 숫자보다 더 작은 게 있는지 확인하는 문제. class Solution { public: vector finalPrices(vector& prices) { vector ans; bool flag = false; for(int i = 0;i 2020. 6. 29. 17] Leetcode 1323. Maximum 69 Number 6과 9로 이뤄진 숫자가 주어졌을 때 단 하나의 6을 9로 바꿨을 때의 최댓값을 리턴하는 문제 Maximum 69 Number - 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 주어진 숫자에서 6이 있는 가장 큰 자릿수를 구해서 그 자릿수에 3을 더 해준다 pow함수 사용 class Solution { public: int maximum69Number (int num) { int max6= -1; // 6이 있는 최대 자릿수 int ans = num; for(i.. 2020. 6. 29. 3] Leetcode 1431. Kids With the Greatest Number of Candies candies 배열과 extra 숫자가 주어질 때 배열의 각 숫자들이 extra 값을 더했을 때 배열에서 가장 큰 값이 될 수 있으면 true, 아니면 false를 반환하는 문제. 배열에서 최댓값 구하고 처음부터 돌면서 extra 더했을 때 최댓값과 비교한다. class Solution { public: vector kidsWithCandies(vector& candies, int extraCandies) { vector ans; int maxNum = 0; for(int i = 0;i maxNum) maxNum = candies[i]; for(int i = 0;i= maxNum) ans.push_back(true); else ans.push_back(false); return ans; } }; 2020. 6. 18. 이전 1 2 3 다음