알고리즘 문제풀이/LeetCode
LeetCode 844번 - Backspace String Compare
leetcode.com/problems/backspace-string-compare/ Backspace String Compare - 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: bool backspaceCompare(string S, string T) { int sizes = S.size(); int sizet = T.size(); while(S.find('#') != -1){ if(S.find('#') == 0)..
LeetCode 13번 - Roman to Integer
leetcode.com/problems/roman-to-integer/ Roman to 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 class Solution { public: int romanToInt(string s) { int result = 0; for(int i=0; i
LeetCode 686번- Repeated String Match
leetcode.com/problems/repeated-string-match/ Repeated String Match - 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 repeatedStringMatch(string A, string B) { //1)a를 계속해서 반복 시킨다 b를 찾을때까지. int count = 1; string plus = A; int flag = 0; while(A.size()
LeetCode 67번 - Add Binary
leetcode.com/problems/add-binary/ Add Binary - 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 { // a와 b의 길이를 비교하여 긴 문자를 a로, 짧은 문자를 b로 만든다. // a와 b를 reverse한다.(연산을 쉽게 하기 위해) // a와 b를 b의 길이까지 비교하며 이진수 덧셈을 하며, 연산의 결과는 a에 저장한다. // a에서 (b의 길이, a의 길이)를 살펴보며 2 이상이면 자릿수를 올려..
LeetCode 14번 - Longest Common Prefix
leetcode.com/problems/longest-common-prefix/ Longest Common Prefix - 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 compare(string a, string b){ return a.size() < b.size(); } class Solution { public: string longestCommonPrefix(vector& strs) { string result = ""; if(strs.size()..
LeetCode 81번 - Search in Rotated Sorted Array II
leetcode.com/problems/search-in-rotated-sorted-array-ii/submissions/ Search in Rotated Sorted Array II - 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 search(vector& nums, int target) { set s(nums.begin(),nums.end()); if(s.count(target)){ return true;..