ํ‹ฐ์Šคํ† ๋ฆฌ

JuHyeong.dev
๊ฒ€์ƒ‰ํ•˜๊ธฐ

๋ธ”๋กœ๊ทธ ํ™ˆ

JuHyeong.dev

dkswnkk.tistory.com/m

์–ด์ œ๋ณด๋‹ค ๋‚˜์€, ์˜ค๋Š˜๋ณด๋‹ค ์„ฑ์žฅํ•œ ๋‚ด์ผ

๊ตฌ๋…์ž
123
๋ฐฉ๋ช…๋ก ๋ฐฉ๋ฌธํ•˜๊ธฐ

์ฃผ์š” ๊ธ€ ๋ชฉ๋ก

  • [Leetcode,c++] Add Digits ๋ฌธ์ œ https://leetcode.com/problems/add-digits/ Add 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 ์ฝ”๋“œ (1) ์žฌ๊ท€, ๋ฐ˜๋ณต๋ฌธ์„ ์‚ฌ์šฉํ•œ ํ’€์ด class Solution { public: int addDigits(int num) { int temp1=0, temp2=0, ans=num; while(true){ while(num>9){ temp1 = num%10; temp2 = num/10; ans = temp1 +.. ๊ณต๊ฐ์ˆ˜ 0 ๋Œ“๊ธ€์ˆ˜ 0 2022. 3. 2.
  • [Leetcode,c++] Happy Number ๋ฌธ์ œ Happy 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 ์ฝ”๋“œ class Solution { public: bool isHappy(int n) { string s; s = to_string(n); while(true){ unsigned long long temp = 0; for(int i=0; i ๊ณต๊ฐ์ˆ˜ 0 ๋Œ“๊ธ€์ˆ˜ 0 2022. 3. 2.
  • [Leetcode,c++] Majority Element ๋ฌธ์ œ Majority Element - 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 majorityElement(vector& nums) { mapm; for(int i:nums) m[i]++; int cnt=-1,ans; for(auto it=m.begin(); it!=m.end(); it++){ if(it->second>cnt){ cnt=it->second; ans=it->first; }; } ret.. ๊ณต๊ฐ์ˆ˜ 0 ๋Œ“๊ธ€์ˆ˜ 0 2021. 11. 28.
  • [Leetcode,c++] Network Delay Time ๋ฌธ์ œ Network Delay Time - 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: vectorgraph[101]; int d[101]; void dijkstra(int start){ priority_queuepq; pq.push({0,start}); d[start]=0; while(!pq.empty()){ int dist = -pq.top().first; int now = pq.top().second; p.. ๊ณต๊ฐ์ˆ˜ 0 ๋Œ“๊ธ€์ˆ˜ 0 2021. 11. 22.
  • [Leetcode,c++] Valid Anagram ๋ฌธ์ œ Valid Anagram - 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 isAnagram(string s, string t) { sort(s.begin(),s.end()); sort(t.begin(),t.end()); if(t==s) return true; else return false; } }; ํ’€์ด Anagram ์ด๋ž€ ํ•œ ๋ฌธ์ž์—ด์˜ ๋ฌธ์ž๋ฅผ ๋น ์ง์—†์ด ์‚ฌ์šฉํ•˜์—ฌ ๋‹ค๋ฅธ ๋ฌธ์ž์—ด์„ ๋งŒ๋“ค ์ˆ˜ ์žˆ๋Š” ๊ฒฝ์šฐ๋ฅผ.. ๊ณต๊ฐ์ˆ˜ 0 ๋Œ“๊ธ€์ˆ˜ 0 2021. 11. 20.
  • [Leetcode,c++] Single Number ๋ฌธ์ œ Single 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 ์ฝ”๋“œ class Solution { public: int singleNumber(vector& nums) { mapm; int ans; for(int i:nums) m[i]++; for(auto it = m.begin(); it!=m.end(); it++){ if(it->second==1){ ans=it->first; break; } } return ans; } }; ํ’€์ด ๋‹จ์ˆœํžˆ ๋ฐฐ.. ๊ณต๊ฐ์ˆ˜ 0 ๋Œ“๊ธ€์ˆ˜ 0 2021. 11. 19.
  • [Leetcode,c++] Combination Sum II ๋ฌธ์ œ Combination Sum 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: void dfs(int index, vector& candidates, int target, vector& ans, vector&current){ if(target==0){ ans.push_back(current); return; } for(int i=index; iindex && candidates[i]==candidate.. ๊ณต๊ฐ์ˆ˜ 0 ๋Œ“๊ธ€์ˆ˜ 0 2021. 11. 16.
  • [Leetcode,c++] Subsets II ๋ฌธ์ œ Subsets 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: mapvisited; vectorans; void dfs(int num, vector&nums,vectorcurrent){ sort(current.begin(),current.end()); if(!visited[current]){ ans.push_back(current); visited[current]=1; } if(num>nums.siz.. ๊ณต๊ฐ์ˆ˜ 0 ๋Œ“๊ธ€์ˆ˜ 0 2021. 11. 15.
  • [Leetcode,c++] Rotate Image ๋ฌธ์ œ Rotate Image - 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: void rotate(vector& matrix) { int n = matrix.size(); vectorans(n); for(int i=0; i=0; k--){ ans[i].push_back(matrix[k][i]); } } matrix = ans; } }; ์ œ์ž๋ฆฌ ํšŒ์ „ class Solution { public: .. ๊ณต๊ฐ์ˆ˜ 1 ๋Œ“๊ธ€์ˆ˜ 0 2021. 11. 15.
  • [Leetcode,c++] Permutations II ๋ฌธ์ œ Permutations 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: vector permuteUnique(vector& nums) { vectorans; sort(nums.begin(),nums.end()); do{ ans.push_back(nums); }while(next_permutation(nums.begin(),nums.end())); return ans; } }; ๊ณต๊ฐ์ˆ˜ 0 ๋Œ“๊ธ€์ˆ˜ 0 2021. 11. 15.
  • [Leetcode,c++] 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 sum=0; int roman_to_int(char c1,char c2){ bool flag = true; if(c1=='I'){ if(c2=='V'){ sum+=4; flag = false; } else if(c2 =='X'){ sum+=9; flag = false; } else sum+=1; } else if(c1==.. ๊ณต๊ฐ์ˆ˜ 0 ๋Œ“๊ธ€์ˆ˜ 0 2021. 11. 15.
  • [Leetcode,c++] Find First and Last Position of Element in Sorted Array ๋ฌธ์ œ Find First and Last Position of Element in 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: vector searchRange(vector& nums, int target) { int start = 0; int end = nums.size()-1; int first_index = -1,last_index = -1; vectorans; while(sta.. ๊ณต๊ฐ์ˆ˜ 0 ๋Œ“๊ธ€์ˆ˜ 0 2021. 11. 14.
  • [Leetcode,c++] Group Anagrams ๋ฌธ์ œ Group Anagrams - 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 groupAnagrams(vector& strs) { mapm; mapchar_check; sort(strs.begin(),strs.end()); vectortemp = strs; for(int i=0; i ๊ณต๊ฐ์ˆ˜ 0 ๋Œ“๊ธ€์ˆ˜ 0 2021. 11. 14.
  • [Leetcode,c++] Next Permutation ๋ฌธ์ œ Next Permutation - 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: void nextPermutation(vector& nums) { next_permutation(nums.begin(),nums.end()); } }; ๊ณต๊ฐ์ˆ˜ 0 ๋Œ“๊ธ€์ˆ˜ 0 2021. 11. 14.
  • [Leetcode,c++] Length of Last Word ๋ฌธ์ œ Length of Last Word - 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 lengthOfLastWord(string s) { vectorparsing; string temp; for(int i=0; i ๊ณต๊ฐ์ˆ˜ 0 ๋Œ“๊ธ€์ˆ˜ 0 2021. 11. 14.
  • [Leetcode,c++] Container With Most Water ๋ฌธ์ œ Container With Most Water - 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 maxArea(vector& height) { int start = 0; int end = height.size()-1; int ans = -1; while(start ๊ณต๊ฐ์ˆ˜ 0 ๋Œ“๊ธ€์ˆ˜ 0 2021. 11. 14.
  • [Leetcode,c++] Remove Duplicates from Sorted Array ๋ฌธ์ œ Remove Duplicates from 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 removeDuplicates(vector& nums) { nums.erase(unique(nums.begin(),nums.end()),nums.end()); return nums.size(); } }; ๊ณต๊ฐ์ˆ˜ 0 ๋Œ“๊ธ€์ˆ˜ 0 2021. 11. 14.
  • [Leetcode,c++] 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 ์ฝ”๋“œ class Solution { public: string longestCommonPrefix(vector& strs) { string ans=""; for(int i=0; i ๊ณต๊ฐ์ˆ˜ 0 ๋Œ“๊ธ€์ˆ˜ 0 2021. 11. 11.
  • [Leetcode,c++] Permutations ๋ฌธ์ œ Permutations - 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 permute(vector& nums) { vectorans; sort(nums.begin(),nums.end()); do{ ans.push_back(nums); }while(next_permutation(nums.begin(),nums.end())); return ans; } }; ํ’€์ด ๋‹จ์ˆœํ•˜๊ฒŒ ์ˆœ์—ด์„ ๊ตฌํ•˜๋Š” ๋ฌธ์ œ์ž…๋‹ˆ๋‹ค... ๊ณต๊ฐ์ˆ˜ 0 ๋Œ“๊ธ€์ˆ˜ 0 2021. 11. 10.
  • [Leetcode,c++] Best Time to Buy and Sell Stock ๋ฌธ์ œ Best Time to Buy and Sell Stock - 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 maxProfit(vector& prices) { int min_index,min_value=1e9,ans; for(int i=0; i ๊ณต๊ฐ์ˆ˜ 0 ๋Œ“๊ธ€์ˆ˜ 0 2021. 11. 10.
  • [Leetcode,c++] Climbing Stairs ๋ฌธ์ œ Climbing Stairs - 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 climbStairs(int n) { int dp[46]; dp[1]=1; dp[2]=2; for(int i=3; i ๊ณต๊ฐ์ˆ˜ 0 ๋Œ“๊ธ€์ˆ˜ 0 2021. 11. 9.
  • [Leetcode,c++] Maximum Subarray ๋ฌธ์ œ Maximum Subarray - 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 maxSubArray(vector& nums) { int dp[100001]={0, }; int ans=-1e9; if(nums.size()==1) return nums.back(); for(int i=0; i ๊ณต๊ฐ์ˆ˜ 0 ๋Œ“๊ธ€์ˆ˜ 0 2021. 11. 9.
  • [Leetcode,c++] Valid Parentheses ๋ฌธ์ œ Valid Parentheses - 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 isValid(string s) { stackst; for(int i=0; i ๊ณต๊ฐ์ˆ˜ 0 ๋Œ“๊ธ€์ˆ˜ 0 2021. 11. 9.
  • [Leetcode,c++] Palindrome Number ๋ฌธ์ œ Palindrome 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 ์ฝ”๋“œ class Solution { public: bool isPalindrome(int x) { if(x ๊ณต๊ฐ์ˆ˜ 0 ๋Œ“๊ธ€์ˆ˜ 0 2021. 11. 9.
  • [Leetcode,c++] Search Insert Position ๋ฌธ์ œ Search Insert Position - 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 searchInsert(vector& nums, int target) { int start = 0; int end = nums.size(); int ans = 0; sort(nums.begin(),nums.end()); while(start=nums.size()) break; if(target == nums[m.. ๊ณต๊ฐ์ˆ˜ 0 ๋Œ“๊ธ€์ˆ˜ 0 2021. 11. 9.
  • [Leetcode,c++] Find the City With the Smallest Number of Neighbors at a Threshold Distance ๋ฌธ์ œ Find the City With the Smallest Number of Neighbors at a Threshold Distance - 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 { int graph[101][101]={0,}; public: int findTheCity(int n, vector& edges, int distanceThreshold) { for (int i = 0; i < 101; i++) { fill.. ๊ณต๊ฐ์ˆ˜ 0 ๋Œ“๊ธ€์ˆ˜ 0 2021. 11. 7.
  • [Leetcode,c++] Combination Sum ๋ฌธ์ œ Combination Sum - 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 { mapduplicate; public: vectorans; void dfs(vector &candidates,int &target,int sum,vector route){ if(sum==target){ sort(route.begin(),route.end()); if(duplicate[route]==0){ duplicate[route]++; an.. ๊ณต๊ฐ์ˆ˜ 0 ๋Œ“๊ธ€์ˆ˜ 0 2021. 11. 7.
  • [Leetcode,c++] Multiply-Strings ๋ฌธ์ œ Multiply 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 ์ฝ”๋“œ class Solution { public: string multiply(string num1, string num2) { if(num1 == "0" || num2 == "0") return "0"; vector v(num1.length() + num2.length(), 0); for(int i = num1.length()-1; i >= 0; i--){ for(int k .. ๊ณต๊ฐ์ˆ˜ 0 ๋Œ“๊ธ€์ˆ˜ 0 2021. 11. 7.
  • [Leetcode,c++] Longest Common Subsequence Longest Common Subsequence - 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 longestCommonSubsequence(string text1, string text2) { int dp[1001][1001]; for(int i=1; i ๊ณต๊ฐ์ˆ˜ 0 ๋Œ“๊ธ€์ˆ˜ 0 2021. 10. 23.
  • [Leetcode,c++] Robot Bounded In Circle Robot Bounded In Circle - 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 isRobotBounded(string instructions) { int visited[101][101]; int x=0,y=0,dir=0; //e(0),w(1),s(2),n(3) int cnt=4; while(cnt--){ for(int i=0; i3) dir=0; } if(cmd=='R'){ dir-=1; if(.. ๊ณต๊ฐ์ˆ˜ 0 ๋Œ“๊ธ€์ˆ˜ 0 2021. 10. 23.
    ๋ฌธ์˜์•ˆ๋‚ด
    • ํ‹ฐ์Šคํ† ๋ฆฌ
    • ๋กœ๊ทธ์ธ
    • ๊ณ ๊ฐ์„ผํ„ฐ

    ํ‹ฐ์Šคํ† ๋ฆฌ๋Š” ์นด์นด์˜ค์—์„œ ์‚ฌ๋ž‘์„ ๋‹ด์•„ ๋งŒ๋“ญ๋‹ˆ๋‹ค.

    ยฉ Kakao Corp.