본문 바로가기

IT/알고리즘90

14] Leetcode 1221. Split a String in Balanced Strings Split a String in Balanced Strings - 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 R과 L로 구성된 문자열을 R과 L의 개수가 똑같은 문자열로 나누려고 한다. 가장 많이 쪼갰을 때 그 숫자를 리턴하는 문제. 살짝 헷갈릴 수도 있지만 그냥 앞에서부터 R, L 개수를 각각 세면서 둘이 같아질 때를 리턴하면 된다. class Solution { public: int balancedStringSplit(string s) { int ans=.. 2020. 6. 25.
13] Leetcode 709. To Lower Case To Lower Case - 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: string toLowerCase(string str) { for(int i=0;i='A' && str[i] 2020. 6. 25.
12] Leetcode 1486. XOR Operation in an Array 배타적 논리합, XOR 연산에 관한 문제다. XOR Operation in an Array - 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 초기값만 start로 해주고 나머지는 이어서 고대로 해주면 된다. class Solution { public: int xorOperation(int n, int start) { int ans = start; for(int i = 1;i 2020. 6. 24.
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.