일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- nginx
- bash
- type
- dotenv
- C#
- property
- git
- docker
- vuetify
- 보안
- scss
- VUE
- npm
- var
- machine learning
- security
- BOJ
- condition
- vue.js
- Clone
- loop
- JavaScript
- leetcode
- generic
- TypeScript
- C++
- AI
- webpack
- 앙상블
- Python
- Today
- Total
목록PS/LeetCode (49)
ice rabbit programming
https://leetcode.com/problems/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 주어진 배열의 부분집합 중 가장 합이 큰 경우이다. 사실 이 때까지 푼 easy 단계 중 가장 생각이 오래 걸렸던 것 같다. 연속된 합이 가장 큰 경우의 결과값을 return하였다. class Solution { public: int maxSubArray(vector& nums) { int ans=..
https://leetcode.com/problems/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 괄호가 유효한지 검사하는 전형적인 stack 문제이다. class Solution { public: bool isValid(string s) { stack* sc = new stack(); for(int i=0;ipush(s[i]); break; case '{': sc->push(s[i]); b..
https://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 ](https://leetcode.com/problems/longest-common-prefix/) 겹치는 가장 긴 prefix를 구하는 문제이다. 단순하게 풀었다. 이 문제도 C# // C# public class Solution { public string LongestCo..
https://leetcode.com/problems/remove-element/ [ Remove 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 ](https://leetcode.com/problems/remove-element/) 이전 문제와 비슷하게 반환 값만큼 input array를 검사한다. 다만 전 문제보다 조금 쉬운 듯? 그냥 제거한 만큼 앞으로 당겼다. 이 문제도 C#으로 풀었다. // C# public class Solution ..
https://leetcode.com/problems/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 특이하게 반환값 자체가 답이 아니라, 반환값 만큼 배열을 검사해서 답을 체크하는 문제였다. 아마 이 때문에 비추가 많은 듯.. 이 문제도 C#으로 풀었다. // C# public class Solution { public int R..
https://leetcode.com/problems/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 팰린드롬 숫자, 앞뒤가 같은 숫자를 판별하는 문제이다. BOJ에서도 비슷한 문제를 풀었었다. 문제에서 음수는 팰린드롬으로 취급받지 않으므로 걸러낸 후에, string으로 변환하여 대칭을 비교하였다. 이번엔 C++이 아닌 C#으로 풀었다. public class Solution { public b..
https://leetcode.com/problems/reverse-integer/ Reverse 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 제목 그대로 단순히 숫자를 거꾸로 뒤집는 문제이다. 처음 봤을 때는 고전적으로 %해가며 담는 것을 생각했으나 string 변환을 통해 뒤집는 것으로 생각을 바꾸었다. atoi 함수를 이용했다(https://docs.microsoft.com/ko-kr/cpp/c-runtime-library/referen..
https://leetcode.com/problems/merge-two-sorted-lists/ Merge Two Sorted Lists - 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. 일단 합치고 정렬한다. 2. node를 받으며 정렬 순서대로 넣는다. 1번의 경우에는 O(nlogn)의 정렬을 쓰면 될 것 같긴 했지만 2번으로 풀기로 생각했다. C++..