STL 是 C++ 标准库的一部分,目前三大操作系统的标准库实现各不相同,Linux 下 GCC 使用的是 libstdc++,Mac OS 下 Clang 使用的是 libc++,Windows 下 Visual Studio 的MSVC 使用的是 MSVC STL STL 提供了一些较为通用的数据结构,这些数据结构在 C++ 中称为容器,C++11 中包含如下容器 序列容器(能
Longest Common Subsequence -https://leetcode.com/problems/longest-common-subsequence/ Word Break Problem -https://leetcode.com/problems/word-break/ Combination Sum -https://leetcode.com/problems/combination-sum-iv/ House Robber -https://leetcode.com/problems/house-robber/ ...
intfindShortestSubArray(vector<int>&nums){unordered_map<int,vector<int>>m1;//第二项是个vectorfor(int i=0;i<nums.size();i++)m1[nums[i]].push_back(i);//统计元素的出现位置int max1=INT_MIN;for(auto iter=m1.begin();iter!=m1.end();iter++)//遍历map找到出现的最多次数max1=max(max...
classSolution{public:intfindMaxLength(vector<int>& nums){ unordered_map<int,int> ext;intmaxlen =0, sum =0, n = nums.size();for(inti =0; i < n; i ++) { sum += (nums[i] ==0) ?-1:1;if(sum ==0) { maxlen =max(maxlen, i +1); }else{if(ext[sum] !=0) { maxlen...
Open with GitHub Desktop Download ZIP This branch is 3909 commits ahead, 5260 commits behind 30-seconds:master. Pull request Compare Latest commit Git stats 3,909 commits Files Permalink Failed to load latest commit information. Type Name Latest commit message Commit time .github .travis...
Would have solved 2nd problem too easily but getline function was not working in my Visual Studio for some unknown reason. Kuee completed his 100 days of code today! Check this out to know more of his really inspirational journey. Thanks for helping so much and Kudos my friend 😊🥳🥳...
class Solution: def lengthOfLongestSubstring(self, s: str) -> int: i, r, d = 0, 0, {} for j, c in enumerate(s): i, r, d[c] = max(i, d.get(c, -1) + 1), max(r, j - i), j return max(r, len(s) - i) 双指针滑动窗口 i 代表起始位置,r 记录最优解,d 是一个...
Windows(可用):Visual Studio(MSVC) 16.8版本以上 macOS(可用):Apple Clang 或 GCC C++单元测试采用 Google Test ,性能测试采用 Google Benchmark ,二者在CMake构建中会拉取最新源码,需要环境自带Git。 将检测编译器是否支持 AddressSanitizer 内存检查功能,若支持将启用。Go...
LeetCode Problems 一. 目录 #TitleSolutionAcceptanceDifficultyFrequency 0001 Two Sum Go 45.6% Easy 0002 Add Two Numbers Go 33.9% Medium 0003 Longest Substring Without Repeating Characters Go 30.4% Medium 0004 Median of Two Sorted Arrays Go...
LeetCode Problems 一. 目录 #TitleSolutionAcceptanceDifficultyFrequency 0001 Two Sum Go 45.6% Easy 0002 Add Two Numbers Go 33.9% Medium 0003 Longest Substring Without Repeating Characters Go 30.4% Medium 0004 Median of Two Sorted Arrays