본문 바로가기

전체 글310

11] Leetcode 1295. Find Numbers with Even Number of Digits 숫자들 중에 짝수 자릿수인 숫자의 개수를 반환하는 문제. Find Numbers with Even Number of Digits - 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 findNumbers(vector& nums) { int ans = 0; int sth =0; for(int i = 0; i 2020. 6. 24.
10] Leetcode 1389. Create Target Array in the Given Order Create Target Array in the Given Order - 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 int 벡터에 원하는 위치에 숫자를 넣는 문제. class Solution { public: vector createTargetArray(vector& nums, vector& index) { vectorans; for(int i = 0;i 2020. 6. 23.
9] Leetcode 1281. Subtract the Product and Sum of Digits of an Integer Subtract the Product and Sum of Digits of an Integer - 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 주어진 숫자를 자릿수 별로 쪼개는 문제다. 일의 자리부터 계산하고 떼버리고?를 0이 될때까지 한다. 곱하는 건 초기값이 1, 더하는 건 0으로 ~ class Solution { public: int subtractProductAndSum(int n) { int product = 1; int sum = 0; while(n.. 2020. 6. 22.
8] Leetcode 1313. Decompress Run-Length Encoded List Decompress Run-Length Encoded List - 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: vector decompressRLElist(vector& nums) { vectorans; for(int i = 0; i 2020. 6. 21.
7] Leetcode 1365. How Many Numbers Are Smaller Than the Current Number 숫자로 이뤄진 벡터내에 각 벡터값보다 작은 값의 갯수를 반환하는 문제. How Many Numbers Are Smaller Than the Current 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 역시 이중 for문을 통해 해결했다. class Solution { public: vector smallerNumbersThanCurrent(vector& nums) { vectorans; int cnt = 0; for(int i=0; i 2020. 6. 21.
6] Leetcode 771. Jewels and Stones Jewels and Stones - 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 numJewelsInStones(string J, string S) { int ans = 0; for(int i = 0;i 2020. 6. 21.