일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- Class
- LeetCode
- Protocol
- data science
- Substring with Concatenation of All Words
- 시바견
- iterator
- 운영체제
- concurrency
- kaggle
- 컴퓨터의 구조
- 파이썬
- 밴픽
- 109. Convert Sorted List to Binary Search Tree
- Decorator
- 프로그래머스
- Regular Expression
- 315. Count of Smaller Numbers After Self
- DWG
- Python
- Generator
- t1
- attribute
- Python Implementation
- 43. Multiply Strings
- Python Code
- Convert Sorted List to Binary Search Tree
- 715. Range Module
- 30. Substring with Concatenation of All Words
- shiba
- Today
- Total
목록분류 전체보기 (407)
Scribbling
276. Paint Fence https://leetcode.com/problems/paint-fence/ Paint Fence - LeetCode Can you solve this real interview question? Paint Fence - 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 let dp[i] be # of all ways painting i-th fence: then, dp[i] = num_same(i) + num_diff(i) holds. (where ..
1. Function types a) return type: int, arg type: double (function) int func(double) int (double) b) return type: &int[2][3], arg type: double (function) int (*func(double))[2][3] int (*(double))[2][3] c) return type: function pointer of (b), arg type: double (function pointer) int (*(*)(double))[2][3] d) return type: int[2][3], arg type: vector (function) int (std::vector)[2][3] 2. typedef typed..
#include #include #include #include #include #include #include #include #include using namespace std; class Solution { public: int solution(int n, int m, vector& burstTime) { int ret = accumulate(burstTime.begin(), burstTime.end(), 0); int left = *max_element(burstTime.begin(), burstTime.end()); int right = ret; while (left
LeetCode 34. Find First and Last Position of Element in Sorted Array https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/ Find First and Last Position of Element in Sorted Array - LeetCode Can you solve this real interview question? Find First and Last Position of Element in Sorted Array - Given an array of integers nums sorted in non-decreasing order, find the ..
LeetCode 125. Valid Palindrome https://leetcode.com/problems/valid-palindrome/ Valid Palindrome - LeetCode Can you solve this real interview question? Valid Palindrome - A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Alphanumeric cha leetcode.com class Solution { publ..
https://leetcode.com/problems/longest-consecutive-sequence/ class Solution { public: int longestConsecutive(vector& nums) { int ret = 0; unordered_set num_set(nums.begin(), nums.end()); for (int num : nums) { // not found if (num_set.find(num - 1) == num_set.end()) { int cnt = 0; while (num_set.find(num) != num_set.end()) { num += 1; cnt += 1; } ret = max(ret, cnt); } } return ret; } };
https://leetcode.com/problems/product-of-array-except-self/ class Solution { public: vector productExceptSelf(vector& nums) { vector zero_idx; int zero_cnt = 0; vector dp1(nums.size()); vector dp2(nums.size()); int prod = 1; for (int i = 0; i < nums.size(); i++) { int num = nums[i]; if (num == 0) { zero_idx.push_back(i); zero_cnt++; } else { prod *= num; dp1[i] = prod; } } prod = 1; for (int i =..
LeetCode 347. Top K Frequent Elements https://leetcode.com/problems/top-k-frequent-elements/ Top K Frequent Elements - LeetCode Can you solve this real interview question? Top K Frequent Elements - Given an integer array nums and an integer k, return the k most frequent elements. You may return the answer in any order. Example 1: Input: nums = [1,1,1,2,2,3], k = 2 Output: [1,2] leetcode.com stru..
class Solution { public: vector groupAnagrams(vector& strs) { unordered_map map; for (string str : strs) { string sorted_str = str; sort(sorted_str.begin(), sorted_str.end()); map[sorted_str].push_back(str); } vector ret; for (auto e : map) { ret.push_back(e.second); } return ret; } };
https://leetcode.com/problems/valid-anagram/ class Solution { public: bool isAnagram(string s, string t) { if (s.size() != t.size()) { return false; } unordered_map map1; unordered_map map2; for (auto c : s) { map1[c]++; } for (auto c : t) { map2[c]++; } for (auto x : map1) { if (x.second != map2[x.first]) { return false; } } return true; } };