当前位置: 首页 > news >正文

php网站开发简介架设网站是自己架设服务器还是租服务器

php网站开发简介,架设网站是自己架设服务器还是租服务器,免费的那种软件,windows wordpress可以文章目录 一、哈希1.两数之和2.字母异位词分组3.最长连续序列 二、双指针4. 移动零5.盛最多水的容器6.三数之和7.接雨水 三、滑动窗口8.无重复字符的最长子串9.找到字符串中所有字母异位词 四、子串10.和为 K 的子数组 一、哈希 1.两数之和 1. 两数之和 class Solution { pu… 文章目录 一、哈希1.两数之和2.字母异位词分组3.最长连续序列 二、双指针4. 移动零5.盛最多水的容器6.三数之和7.接雨水 三、滑动窗口8.无重复字符的最长子串9.找到字符串中所有字母异位词 四、子串10.和为 K 的子数组 一、哈希 1.两数之和 1. 两数之和 class Solution { public:vectorint twoSum(vectorint nums, int target) {unordered_mapint,int mp;for (int i 0; i nums.size(); i) {auto num mp.find(target - nums[i]);if (num ! mp.end()) {return {i,num - second};}else {mp[nums[i]] i;}}return {-1,-1};} };2.字母异位词分组 49. 字母异位词分组 class Solution { public:vectorvectorstring groupAnagrams(vectorstring strs) {vectorvectorstring res;if (strs.size() 0)return res;unordered_mapstring,vectorstring mp;for (auto t : strs) {string str t;sort(str.begin(),str.end());mp[str].push_back(t);}for (auto it mp.begin(); it ! mp.end(); it ) {res.push_back(it - second);}return res;} };3.最长连续序列 128. 最长连续序列 class Solution { public:int longestConsecutive(vectorint nums) {if (nums.size() 0) return 0;unordered_setint mp;for (const intnun : nums) {mp.insert(num);} int res 0;for (auto ch : mp) {if (!mp.count(ch - 1)) {int curNum ch;int curStreak 1;while (mp.count(curNum 1)) {curNum 1;curStreak 1;}res max(res,curStreak);}}return res;}};二、双指针 4. 移动零 283. 移动零 class Solution { public:void moveZeroes(vectorint nums) {if (nums.size() 0) return ;int slow 0;int fast 0;while (fast nums.size()) {if (nums[fast] ! 0) {nums[slow ] nums[fast];}fast ;}for (int i slow; i nums.size(); i) {nums[i] 0;}} };5.盛最多水的容器 11. 盛最多水的容器 class Solution { public:int maxArea(vectorint height) {int i 0, j height.size() - 1;int res 0;while (i j) {res height[i] height[j] ?max(res,(j - i) * height[i ]) :max(res,(j - i) * height[j --]) ;}return res;} };6.三数之和 15. 三数之和 class Solution { public:vectorvectorint threeSum(vectorint nums) {vectorvectorint res;if (nums.size() 0) return res;sort(nums.begin(),nums.end());if (nums[0] 0) return res;for (int k 0; k nums.size() - 2; k ) {if (k 0 nums[k] nums[k - 1]) continue;int i k 1,j nums.size() - 1;while (i j) {int sum nums[k] nums[i] nums[j];if (sum 0) {while (i j nums[i] nums[i]) ;}else if(sum 0) {while (i j nums[j] nums[--j]) ;}else {res.push_back(vectorint{nums[k], nums[i], nums[j]});while (i j nums[i] nums[i]) ;while (i j nums[j] nums[--j]) ;}}}return res;} };7.接雨水 42. 接雨水 三、滑动窗口 8.无重复字符的最长子串 3. 无重复字符的最长子串 class Solution { public:int lengthOfLongestSubstring(string s) {unordered_mapchar,int windows;int left 0,right 0;int res 0;int n s.size();while (right n) {char c s[right];right ;windows[c] ;while (windows[c] 1) {char d s[left];left ;windows[d] --;}res max(res,right - left);}return res;} };9.找到字符串中所有字母异位词 438. 找到字符串中所有字母异位词 class Solution { public:vectorint findAnagrams(string s, string p) {unordered_mapchar,int need,window;for (char c : p) need[c] ;int left 0,right 0;int vaild 0;vectorint res;while (right s.size()) {char c s[right];right ;if (need.count(c)) { // 如果需要这个元素window[c] ; // 窗口中的值 if (window[c] need[c]) { // 如果窗口中的值和需要的值相等vaild; // 有效值{}}}while (right - left p.size()) { // 当现在的左右差大于子串p的大小if (vaild need.size()) // 如果有效值 needres.push_back(left); // 加入char d s[left]; // 缩小窗口left ;if (need.count(d)) {if (window[d] need[d])vaild--;window[d]--;}}}return res;} };四、子串 10.和为 K 的子数组 560. 和为 K 的子数组 class Solution { public:int subarraySum(vectorint nums, int k) {unordered_mapint,int mp;mp[0] 1;int count 0,pre 0;for (auto x : nums) {pre x;if (mp.find(pre - k) ! mp.end()) {count mp[pre - k];}mp[pre] ;}return count;} };
http://www.pierceye.com/news/278290/

相关文章:

  • 做o2o平台网站需要多少钱买卖域名的网站好
  • 网站设计 手写室内设计奖项有哪些
  • 做电影网站需要那种服务器本地电脑搭建服务器
  • 分析某个网站建设百度知道一下首页
  • 贵池区城乡与住房建设网站建站快车是什么
  • 建站程序aspiis 默认网站 删除
  • 手机开网店的免费平台河南seo推广多少钱
  • 网站app推广怎么做wordpress 手机号注册
  • 网站开发到上线需要多久骆驼有没有做网站的公司
  • 中小企业网站建设示范平台wordpress停用react
  • 网站怎样防止攻击seo顾问培训
  • 网站建设后需要维护吗微信安全中心官网
  • dw可以做h5网站设计素材网站0
  • 建设银行郑州中心支行网站青海商会网站建设公司
  • 国外小型网站中国视觉设计网
  • 沈阳专业网站制作团队泰安网络软件公司
  • 网站建设招聘兼职0基础建站教程
  • 如何从零开始做网站文学网站建设平台
  • 企业网站的网址通常包含dchaser wordpress
  • 什么是做网站flash是怎么做网站的
  • 什么是速成网站石家庄网站建设就找
  • 张家界网站建设要求滨州网站建设费用
  • wordpress订阅插件南昌优化排名推广
  • 国外做网站公司能赚钱吗wordpress登录锚点弹
  • 微网站平台微网站建设方案邢台市有几个区几个县
  • 茶叶外贸网站建设中国建设银行是国企还是央企
  • 成都网站建设公司有哪些内容必应搜索
  • 青岛建设集团招聘信息网站公司官网怎么制作
  • 本溪网站开发公司电话县蒙文网站建设汇报
  • 广州建网站有哪些怎么做网站建设赚钱