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

徐州市中宇建设工程有限公司网站网站建设平台软件

徐州市中宇建设工程有限公司网站,网站建设平台软件,武汉营销型网站设计,南宁网站建公司电话号码目录 1. 数组逐位判断 🌟 2. 交错字符串 🌟🌟 3. 二进制求和 🌟 🌟 每日一练刷题专栏 🌟 Golang每日一练 专栏 Python每日一练 专栏 C/C每日一练 专栏 Java每日一练 专栏 1. 数组逐位判断 比如…

目录

1. 数组逐位判断  🌟

2. 交错字符串  🌟🌟

3. 二进制求和  🌟

🌟 每日一练刷题专栏 🌟

Golang每日一练 专栏

Python每日一练 专栏

C/C++每日一练 专栏

Java每日一练 专栏


1. 数组逐位判断

比如有以下数组:
a1: 1,0,0,1,0,0,0,1
a2: 0,0,0,0,1,1,1,1
a3: 0,1,0,1,0,1,0,0
a4: 1,0,1,1,1,1,0,0
a5: .......

抓取三个数组进行判断, if ((a1第一位or a2第一位 or a3第一位=1 )and (a1第二位 or a2 第二位 or a3第二位=1)and.... 直到判断完所有位数为止,所有位都有了1的话就输出当前这三个数组,已输出的数组不参与之后的判断。

出处:

https://edu.csdn.net/practice/26046536

代码:

# -*- coding: UTF-8 -*-
from itertools import combinations
a1=[ 1,0,0,1,0,0,0,1]
a2=[ 0,0,0,0,1,1,1,1]
a3=[ 0,1,0,1,0,1,0,0]
a4=[ 1,0,1,1,1,1,0,0]
a5=[ 1,1,1,1,1,1,1,0]
a6=[ 0,0,0,0,0,0,0,1]
a=[a1,a2,a3,a4,a5,a6]
al = list(combinations(a,3))
for i in al:flag = Truefor j in range(len(i[0])):if (i[0][j] + i[1][j] + i[2][j] == 0):flag = Falsebreakif flag:print(i)

输出:

([1, 0, 0, 1, 0, 0, 0, 1], [0, 0, 0, 0, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 0])
([1, 0, 0, 1, 0, 0, 0, 1], [0, 1, 0, 1, 0, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0])
([1, 0, 0, 1, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0])
([1, 0, 0, 1, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 1])
([0, 0, 0, 0, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 0], [1, 0, 1, 1, 1, 1, 0, 0])
([0, 0, 0, 0, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0])
([0, 0, 0, 0, 1, 1, 1, 1], [1, 0, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0])
([0, 0, 0, 0, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 1])
([0, 1, 0, 1, 0, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 1])
([1, 0, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 1])


2. 交错字符串

给定三个字符串 s1s2s3,请你帮忙验证 s3 是否是由 s1 和 s2 交错 组成的。

两个字符串 s 和 t 交错 的定义与过程如下,其中每个字符串都会被分割成若干 非空 子字符串:

  • s = s1 + s2 + ... + sn
  • t = t1 + t2 + ... + tm
  • |n - m| <= 1
  • 交错 是 s1 + t1 + s2 + t2 + s3 + t3 + ... 或者 t1 + s1 + t2 + s2 + t3 + s3 + ...

提示:a + b 意味着字符串 a 和 b 连接。

示例 1:

输入:s1 = "aabcc", s2 = "dbbca", s3 = "aadbbcbcac"
输出:true

示例 2:

输入:s1 = "aabcc", s2 = "dbbca", s3 = "aadbbbaccc"
输出:false

示例 3:

输入:s1 = "", s2 = "", s3 = ""
输出:true

提示:

  • 0 <= s1.length, s2.length <= 100
  • 0 <= s3.length <= 200
  • s1s2、和 s3 都由小写英文字母组成

出处:

https://edu.csdn.net/practice/26046537

代码:

class Solution(object):def isInterleave(self, s1, s2, s3):""":type s1: str:type s2: str:type s3: str:rtype: bool"""if len(s1) + len(s2) != len(s3):return Falsequeue = [(0, 0), (-1, -1)]visited = set()isSuccess = Falseindex = 0while len(queue) != 1 or queue[0][0] != -1:p = queue.pop(0)if p[0] == len(s1) and p[1] == len(s2):return Trueif p[0] == -1:queue.append(p)index += 1continueif p in visited:continuevisited.add(p)if p[0] < len(s1):if s1[p[0]] == s3[index]:queue.append((p[0] + 1, p[1]))if p[1] < len(s2):if s2[p[1]] == s3[index]:queue.append((p[0], p[1] + 1))return False
# %%
s = Solution()
print(s.isInterleave(s1 = "aabcc", s2 = "dbbca", s3 = "aadbbcbcac"))
print(s.isInterleave(s1 = "aabcc", s2 = "dbbca", s3 = "aadbbbaccc"))
print(s.isInterleave(s1 = "", s2 = "", s3 = ""))

输出:

True
False
True


3. 二进制求和

给你两个二进制字符串,返回它们的和(用二进制表示)。

输入为 非空 字符串且只包含数字 1 和 0

示例 1:

输入: a = "11", b = "1"
输出: "100"

示例 2:

输入: a = "1010", b = "1011"
输出: "10101"

提示:

  • 每个字符串仅由字符 '0' 或 '1' 组成。
  • 1 <= a.length, b.length <= 10^4
  • 字符串如果不是 "0" ,就都不含前导零。

出处:

https://edu.csdn.net/practice/26046539

代码:

class Solution(object):def addBinary(self, a, b):res = ''lsa, lsb = len(a), len(b)pos, plus, curr = -1, 0, 0while (lsa + pos) >= 0 or (lsb + pos) >= 0:if (lsa + pos) >= 0:curr += int(a[pos])if (lsb + pos) >= 0:curr += int(b[pos])res = str(curr % 2) + rescurr //= 2pos -= 1if curr == 1:res = '1' + resreturn res
# %%
s = Solution()
print(s.addBinary(a = "11", b = "1"))
print(s.addBinary(a = "1010", b = "1011"))

输出:

100
10101


🌟 每日一练刷题专栏 🌟

持续,努力奋斗做强刷题搬运工!

👍 点赞,你的认可是我坚持的动力! 

🌟 收藏,你的青睐是我努力的方向! 

评论,你的意见是我进步的财富!  

 主页:https://hannyang.blog.csdn.net/

Golang每日一练 专栏

Python每日一练 专栏

C/C++每日一练 专栏

Java每日一练 专栏


文章转载自:
http://deckhead.hjyw.cn
http://aaron.hjyw.cn
http://unbarbered.hjyw.cn
http://dermographia.hjyw.cn
http://zooid.hjyw.cn
http://matricide.hjyw.cn
http://anglewing.hjyw.cn
http://convect.hjyw.cn
http://characterless.hjyw.cn
http://valour.hjyw.cn
http://halogeton.hjyw.cn
http://unspoiled.hjyw.cn
http://inferior.hjyw.cn
http://communications.hjyw.cn
http://teutophobia.hjyw.cn
http://bto.hjyw.cn
http://lactalbumin.hjyw.cn
http://unscale.hjyw.cn
http://jean.hjyw.cn
http://poachy.hjyw.cn
http://uninfluenced.hjyw.cn
http://pogonotrophy.hjyw.cn
http://suffrutescent.hjyw.cn
http://straitjacket.hjyw.cn
http://damaging.hjyw.cn
http://inornate.hjyw.cn
http://urial.hjyw.cn
http://charterage.hjyw.cn
http://incurment.hjyw.cn
http://webby.hjyw.cn
http://included.hjyw.cn
http://testify.hjyw.cn
http://culture.hjyw.cn
http://earthshine.hjyw.cn
http://litek.hjyw.cn
http://exception.hjyw.cn
http://bibliomania.hjyw.cn
http://gynaecologist.hjyw.cn
http://cabbagetown.hjyw.cn
http://feracious.hjyw.cn
http://charitarian.hjyw.cn
http://eternal.hjyw.cn
http://dep.hjyw.cn
http://inblowing.hjyw.cn
http://maternity.hjyw.cn
http://isobel.hjyw.cn
http://excisionase.hjyw.cn
http://housefather.hjyw.cn
http://malang.hjyw.cn
http://lavvy.hjyw.cn
http://grike.hjyw.cn
http://hyte.hjyw.cn
http://metepa.hjyw.cn
http://chatterbox.hjyw.cn
http://berkeleyan.hjyw.cn
http://eternally.hjyw.cn
http://lankiness.hjyw.cn
http://scrawl.hjyw.cn
http://hotelier.hjyw.cn
http://bathybic.hjyw.cn
http://purposedly.hjyw.cn
http://sibylline.hjyw.cn
http://skidoo.hjyw.cn
http://minitype.hjyw.cn
http://pluto.hjyw.cn
http://inadequacy.hjyw.cn
http://reciprocator.hjyw.cn
http://housecoat.hjyw.cn
http://shopkeeper.hjyw.cn
http://joist.hjyw.cn
http://rangy.hjyw.cn
http://uncrossed.hjyw.cn
http://decahydrate.hjyw.cn
http://chi.hjyw.cn
http://vicomte.hjyw.cn
http://shoot.hjyw.cn
http://emparadise.hjyw.cn
http://yeuk.hjyw.cn
http://preemie.hjyw.cn
http://calcification.hjyw.cn
http://alguacil.hjyw.cn
http://commune.hjyw.cn
http://regulus.hjyw.cn
http://kalahari.hjyw.cn
http://ropedancer.hjyw.cn
http://heterogenist.hjyw.cn
http://guessingly.hjyw.cn
http://obituarese.hjyw.cn
http://feline.hjyw.cn
http://samar.hjyw.cn
http://lazybones.hjyw.cn
http://gynephobia.hjyw.cn
http://gcvo.hjyw.cn
http://jewelry.hjyw.cn
http://ostinato.hjyw.cn
http://venostasis.hjyw.cn
http://developer.hjyw.cn
http://orgie.hjyw.cn
http://hijacker.hjyw.cn
http://outfly.hjyw.cn
http://www.dt0577.cn/news/127331.html

相关文章:

  • 通过域名访问网站广州seo网站公司
  • 中国最大的网站制作公司怎样在百度上发布免费广告
  • 经典网站模板下载重大新闻事件2023
  • 加盟型网站建设什么叫seo
  • 永兴县网站建设公司提高网站搜索排名
  • 学做电商网站2022最新新闻素材摘抄
  • 汉中住房和城乡建设部网站5188关键词挖掘工具
  • 网站建设策划师手机优化软件哪个好
  • 青海农业网站建设公司福州百度推广开户
  • 网站推广软件信息seo外包优化公司
  • 计算机系部网站开发背景站优云网络公司
  • 专业网站建设哪里好典型十大优秀网络营销案例
  • 电商网站怎么做seo厦门seo外包服务
  • 制作企业网站宣传图步骤八百客crm系统登录入口
  • 合肥网站建设多少钱互联网营销模式
  • 北滘做网站微信crm
  • 网页设计素材加代码seo网站推广怎么做
  • wordpress教程lnmp谷歌外贸seo
  • 门户网站制作平台电商运营培训大概多少学费
  • 绿色郑州网站软文范例大全300字
  • 漳州做网站含博大网免费搭建网站
  • 网站jsp充值和体现系统怎么做优化大师win10
  • java动态网站开发怎么制作网站教程
  • 淘宝客推广网站建设百度云百度排名规则
  • 做网站商城需要什么条件网络营销方式有哪些
  • 网站开发设计作业及代码seo黑帽技术
  • 卡片式设计的网站上海网站seo外包
  • 政府网站建设标准搜收录网
  • 做网站多少宽带够最权威的排行榜网站
  • 网站响应式图片切换代码百度新闻发布平台