분류 전체보기

    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;..

    LeetCode 33번 - Search in Rotated Sorted Array

    leetcode.com/problems/search-in-rotated-sorted-array/submissions/ Search in Rotated Sorted 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 class Solution { public: int search(vector& nums, int target) { int l = 0; int r = nums.size()-1; while(l target){ //일반적인 경우와 다를때: r의 값..

    LeetCode 41번 - First Missing Positive

    leetcode.com/problems/first-missing-positive/ First Missing Positive - 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 firstMissingPositive(vector& nums) { set s(nums.begin(),nums.end()); int size = nums.size(); int result = 1; for(result = 1; result