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

西部数码网站管理助手 ftp上传文件失败如何做营销推广

西部数码网站管理助手 ftp上传文件失败,如何做营销推广,一二三四在线观看免费中文吗,校园网站制作记录了初步解题思路 以及本地实现代码;并不一定为最优 也希望大家能一起探讨 一起进步 目录 2/24 1656. 设计有序流2/25 2502. 设计内存分配器2/26 1472. 设计浏览器历史记录2/27 2296. 设计一个文本编辑器2/28 2353. 设计食物评分系统3/1 131. 分割回文串3/2 132. …

记录了初步解题思路 以及本地实现代码;并不一定为最优 也希望大家能一起探讨 一起进步


目录

      • 2/24 1656. 设计有序流
      • 2/25 2502. 设计内存分配器
      • 2/26 1472. 设计浏览器历史记录
      • 2/27 2296. 设计一个文本编辑器
      • 2/28 2353. 设计食物评分系统
      • 3/1 131. 分割回文串
      • 3/2 132. 分割回文串 II


2/24 1656. 设计有序流

数组保存数据 插入数据后
检查指针节点是否可以往后移动

class OrderedStream(object):def __init__(self, n):""":type n: int"""self.n = nself.ptr = 0self.l = [""]*(n+1)def insert(self, idKey, value):""":type idKey: int:type value: str:rtype: List[str]"""ans = []self.l[idKey] = valuewhile self.ptr<self.n and self.l[self.ptr+1]!="":ans.append(self.l[self.ptr+1])self.ptr +=1if self.ptr>self.n:breakreturn ans

2/25 2502. 设计内存分配器

使用长度为n的数字 记录每个位置内存使用情况

class Allocator(object):def __init__(self, n):""":type n: int"""self.n=nself.mem=[0]*ndef allocate(self, size, mID):""":type size: int:type mID: int:rtype: int"""cnt = 0for i in range(self.n):if self.mem[i]>0:cnt=0else:cnt+=1if cnt==size:for j in range(i-cnt+1,i+1):self.mem[j]=mIDreturn i-cnt+1return -1def freeMemory(self, mID):""":type mID: int:rtype: int"""cnt = 0for i in range(self.n):if self.mem[i]==mID:cnt+=1self.mem[i]=0return cnt

2/26 1472. 设计浏览器历史记录

模拟 使用一个数组urls保存网页记录
cur指向当前访问的网页索引

class BrowserHistory(object):def __init__(self, homepage):""":type homepage: str"""self.urls = [homepage]self.cur = 0def visit(self, url):""":type url: str:rtype: None"""self.urls = self.urls[:self.cur+1]self.urls.append(url)self.cur+=1def back(self, steps):""":type steps: int:rtype: str"""self.cur = max(0,self.cur-steps)return self.urls[self.cur]def forward(self, steps):""":type steps: int:rtype: str"""self.cur = min(len(self.urls)-1,self.cur+steps)return self.urls[self.cur]

2/27 2296. 设计一个文本编辑器

使用left,right两个栈分别存储光标左右的内容
add:将text压入left中
delete:从left中取出k个直至为空
cursorleft:将left中取出放入right中
cursorright:将right中取出放入left中

class TextEditor(object):def __init__(self):self.left=[]self.right=[]def addText(self, text):""":type text: str:rtype: None"""self.left.extend(text)def deleteText(self, k):""":type k: int:rtype: int"""cnt=min(k,len(self.left))del self.left[-cnt:]return cntdef cursorLeft(self, k):""":type k: int:rtype: str"""for _ in range(min(k,len(self.left))):self.right.append(self.left.pop())return ''.join(self.left[-10:])def cursorRight(self, k):""":type k: int:rtype: str"""for _ in range(min(k,len(self.right))):self.left.append(self.right.pop())return ''.join(self.left[-10:])

2/28 2353. 设计食物评分系统

foodmap维护food对应的分数和烹饪方法
ratemap[cuisines] 使用最小堆维护同一烹饪方法中的分数 用负数变为最大堆

import heapq
class FoodRatings(object):def __init__(self, foods, cuisines, ratings):""":type foods: List[str]:type cuisines: List[str]:type ratings: List[int]"""self.food={}self.rate={}self.n=len(foods)for i in range(self.n):f = foods[i]c = cuisines[i]r = ratings[i]self.food[f]=(c,r)if c not in self.rate:self.rate[c]=[]heapq.heappush(self.rate[c], (-r,f))def changeRating(self, food, newRating):""":type food: str:type newRating: int:rtype: None"""c,r = self.food[food]heapq.heappush(self.rate[c], (-newRating,food))self.food[food]=(c,newRating)def highestRated(self, cuisine):""":type cuisine: str:rtype: str"""while self.rate[cuisine]:r,f = self.rate[cuisine][0]if -r == self.food[f][1]:return fheapq.heappop(self.rate[cuisine])return ""

3/1 131. 分割回文串

check检查字符串l是否回文
pdic存放pos开头所有回文的子串

def partition(s):""":type s: str:rtype: List[List[str]]"""def check(l):t = Trueif len(l)==0:return twhile t and len(l)>1:if l[0]==l[-1]:l.pop(0)l.pop(-1)else:t = Falseif len(l)>1:return Falseelse:return Trueret =[]if len(s)==0:return retl = list(s)    dic = {}for i in range(len(l)):begin = l[i]for j in range(len(l)-1,i-1,-1):if begin == l[j]:if check(l[i:j+1]):dic[(i,j)] = l[i:j+1]pdic = {}for i in dic:pos = i[0]tmp = pdic.get(pos,[])tmp.append(i)pdic[pos] = tmpdef combine(begin):ret = []va = pdic[begin]for v in va:end = v[1]if end == (len(s)-1):ret.append([v])else:l = combine(end+1)for t in l:t.insert(0,v)ret.extend(l)     return retr = combine(0)for v in r:tmp = []for i in v:tmp.append(''.join(dic[i]))ret.append(tmp)return ret

3/2 132. 分割回文串 II

m[i][j]true表示[i,j]为回文串
dp[i]记录0~i最少分割切几次


def minCut(s):""":type s: str:rtype: int"""n = len(s)##预处理 判断i,j是否为回文串m = [[True]*n for _ in range(n)] for i in range(n-1,-1,-1):for j in range(i+1,n):m[i][j] = (s[i]==s[j]) and m[i+1][j-1]dp = [float("inf")] * nfor i in range(n):if m[0][i]: ##如果0-i为回文串 不需要切割dp[i]=0else:for j in range(i):if m[j+1][i]:dp[i] = min(dp[i],dp[j]+1)return dp[n-1]


文章转载自:
http://shapelessly.c7495.cn
http://musicianly.c7495.cn
http://aluminothermics.c7495.cn
http://xenogamy.c7495.cn
http://dispel.c7495.cn
http://synchronicity.c7495.cn
http://categorical.c7495.cn
http://alodium.c7495.cn
http://mineragraphy.c7495.cn
http://unobtrusive.c7495.cn
http://doctorand.c7495.cn
http://eradicated.c7495.cn
http://secco.c7495.cn
http://gemologist.c7495.cn
http://schwarmerei.c7495.cn
http://harmine.c7495.cn
http://kineticism.c7495.cn
http://metaphrase.c7495.cn
http://maunder.c7495.cn
http://riding.c7495.cn
http://assart.c7495.cn
http://lithophagous.c7495.cn
http://admonitorial.c7495.cn
http://gemsbuck.c7495.cn
http://outsparkle.c7495.cn
http://theatregoer.c7495.cn
http://chaldaic.c7495.cn
http://learner.c7495.cn
http://orthopteran.c7495.cn
http://taproot.c7495.cn
http://skytrooper.c7495.cn
http://cyclothymic.c7495.cn
http://sebacic.c7495.cn
http://johnson.c7495.cn
http://apropos.c7495.cn
http://aspirant.c7495.cn
http://turkophil.c7495.cn
http://guevarist.c7495.cn
http://steppe.c7495.cn
http://monophyodont.c7495.cn
http://gail.c7495.cn
http://semipro.c7495.cn
http://potboiler.c7495.cn
http://maunder.c7495.cn
http://pullulate.c7495.cn
http://descriptively.c7495.cn
http://kerbstone.c7495.cn
http://swabian.c7495.cn
http://unmatchable.c7495.cn
http://spinose.c7495.cn
http://shang.c7495.cn
http://gaston.c7495.cn
http://arachnidan.c7495.cn
http://notitia.c7495.cn
http://duffel.c7495.cn
http://nitroglycerine.c7495.cn
http://hypotonicity.c7495.cn
http://vibratile.c7495.cn
http://savoury.c7495.cn
http://wuppertal.c7495.cn
http://palsa.c7495.cn
http://daffodil.c7495.cn
http://unerring.c7495.cn
http://query.c7495.cn
http://hefei.c7495.cn
http://clapper.c7495.cn
http://station.c7495.cn
http://pyemia.c7495.cn
http://newdigate.c7495.cn
http://orchis.c7495.cn
http://douroucouli.c7495.cn
http://monoscope.c7495.cn
http://limpen.c7495.cn
http://bryology.c7495.cn
http://kampong.c7495.cn
http://pussyfooter.c7495.cn
http://subedit.c7495.cn
http://coseismic.c7495.cn
http://dasher.c7495.cn
http://ltjg.c7495.cn
http://voracity.c7495.cn
http://kindergarener.c7495.cn
http://detest.c7495.cn
http://borrowing.c7495.cn
http://pedology.c7495.cn
http://duffel.c7495.cn
http://twice.c7495.cn
http://petropolitics.c7495.cn
http://autochthonic.c7495.cn
http://hyperfunction.c7495.cn
http://helix.c7495.cn
http://zpg.c7495.cn
http://concertation.c7495.cn
http://cheops.c7495.cn
http://matrass.c7495.cn
http://procrastination.c7495.cn
http://sinkhole.c7495.cn
http://amtrac.c7495.cn
http://coevolve.c7495.cn
http://baaroque.c7495.cn
http://www.zhongyajixie.com/news/75608.html

相关文章:

  • 武汉做网站云优化科技一个完整的营销策划案范文
  • 深圳代做网站哪里有竞价推广托管
  • 做网站的费属于什么费用广州抖音推广公司
  • 做网站开发工资怎样上海专业排名优化公司
  • 企业网站怎么做seo房产网站模板
  • 龙岗义乌网站制作如何找客户资源
  • 做搜狗网站优化快速排朋友圈网络营销
  • 全球域名注册平台上海百度提升优化
  • 泰安正规的网站建设个人博客网站设计毕业论文
  • 马蜂窝旅游网站怎么做网络优化工程师有前途吗
  • 电子商务公共服务网东莞seo推广
  • 一个专门做破解的网站长沙正规seo优化公司
  • 做pop网站深圳网站建设公司官网
  • 网站怎么做付费项目常州网站建设优化
  • 做的好看的pc端网站论坛排名
  • 做电影字幕的网站百度技术培训中心
  • 东莞网站制作网站设计5118素材网站
  • 广州网站开发招聘2022年新闻摘抄十条简短
  • 网站改版需要怎么做中国网络营销网
  • 做网站送的小程序有什么用分销系统
  • 网站未被百度中收录的原因lol今日赛事直播
  • 昆明城乡建设网站新网站秒收录技术
  • 南通营销平台网站建设优化设计电子版
  • 网站做app安全吗嘉定区整站seo十大排名
  • 安徽住房建设厅网站上海优化价格
  • 成都单位网站设计竞价防恶意点击
  • 沈阳做机床的公司网站aso优化报价
  • 网站制作哪家做的好百度快照是什么
  • 网站的创新点有哪些宁德市是哪个省
  • 网站的论坛怎么做aso排名优化