python chanllenge题解】的更多相关文章

网址:chanllenge 修改url最后的html的前缀为答案,就可以过关. 页面上很多只有一幅图片,实际上题目描述全在页面源码中. 然后推荐一个在线代码运行的网站 ideone 查看所有源码:https://github.com/yrhsilence/pythonchallenge 第零题: 题目:要求取2的38次方. 解:python支持**符号表示指数,也可以用match.pow() 2 ** 38 math.pow(2, 38) 第一题: 题目:字符变换,最简单的加密解密方法. 解:字…
题目id: 1 just print a+b give you two var a and b, print the value of a+b, just do it!! print a+b 题目id:  2 list排序 给你一个list L, 如 L=[2,8,3,50], 对L进行升序排序并输出 print sorted(L) 题目id: 3  字符串逆序 给你一个字符串 a, 如a=‘12345’,对a进行逆序输出a. print a[::-1] 题目id:4   输出字典key 给你一…
一起来女装吧 本题改编自USACO(USA Computing Olympiad) 1.1节的第一题 (感谢lsy同学对本题题面的贡献) 直接计算就好了 chr:将ASCII码转成字符 ord:字符对应的ASCII码值 注意:初始化为1,否则会乘0 s1=input() s2=input() sum1=1 sum2=1 for i in s1: sum1*=(ord(i)-ord('A')+1) sum1%=47//边乘边模 for i in s2: sum2*=(ord(i)-ord('A')…
目录 LeetCode Python实现算法简介 0001 两数之和 0002 两数相加 0003 无重复字符的最长子串 0004 寻找两个有序数组的中位数 0005 最长回文子串 0006 Z字型变换 0011 盛最多水的容器 0015 三数之和 0016 最接近的三数之和 0026 删除排序数组中的重复项 0027 移除元素 0031 下一个排列 0033 搜索旋转排序数组 0034 在排序数组中查找元素的第一个和最后一个位置 0035 搜索插入位置 0039 组合总和 0040 组合总和I…
仔细阅读,图画下面的提示(网页的 title 也是重要的提示信息,至少告诉你考察的对象是什么) 1. 238 >> 2**38 274877906944L 根据提示,在 URL 地址处,0.html ⇒ 274877906944.html,来到第二题: 2. map 图文的形式显然是加密和解密, k ⇒ m, o ⇒ q, e ⇒ g 显然是向后退两格(乱码的文本提示使用 string.maketrans() 方法,进行转化): map ⇒ ocr(光学字符识别) import string…
题目描述 [Speech Module]:输入一个数字,将其转换成英文表达形式,字符串中的所有单词必须以一个空格字符分隔. [输入]:一个数字(int) [输出]:代表数字的英文字符串(str) [前提]:0 < number < 1000 [范例]: checkio(4)=='four' checkio(143)=='one hundred forty three' checkio(12)=='twelve' checkio(101)=='one hundred one' checkio(2…
Algorithm 做一个 leetcode 的算法题 Unique Email Addresses https://leetcode.com/problems/unique-email-addresses/ 1)problem 929. Unique Email Addresses Every email consists of a local name and a domain name, separated by the @ sign. For example, in alice@leet…
Problems     # Name     A Infinite Sequence standard input/output 1 s, 256 MB    x3509 B Restoring Painting standard input/output 1 s, 256 MB    x2519 C Money Transfers standard input/output 1 s, 256 MB    x724 D Tree Construction standard input/outp…
题目来源 https://leetcode.com/problems/valid-palindrome/ Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example,"A man, a plan, a canal: Panama" is a palindrome."race a car"…
题目来源 https://leetcode.com/problems/triangle/ Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. For example, given the following triangle [ [], [,4], [6,,7], [4,,8,3] ] The min…
题目来源 https://leetcode.com/problems/pascals-triangle-ii/ Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3,Return [1,3,3,1]. 题意分析 Input:integer Output:kth row of the Pascal's triangle Conditions:只返回第n行 题目思路 同118,不…
题目来源 https://leetcode.com/problems/pascals-triangle/ Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Return [ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] ] 题意分析 Input:integer Output:帕斯卡三角 Conditions:帕斯卡三…
题目来源 https://leetcode.com/problems/populating-next-right-pointers-in-each-node/ Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; } Populate each next pointer to point to its next right node. If th…
题目来源 https://leetcode.com/problems/flatten-binary-tree-to-linked-list/ Given a binary tree, flatten it to a linked list in-place. 题意分析 Input: binary tree Output: flattened tree Conditions:将一个二叉树压平为一个flatten 树,也就是一条斜线 题目思路 先将左右子树压平,然后将左子树嵌入到本节点与右子树之间.…
题目来源 https://leetcode.com/problems/path-sum-ii/ Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. 题意分析 Input: a binary tree, sum Output: list of list. Conditions: 给定一个二叉树,将所有root-leaf的路径值和等于sum的路径返…
题目来源 https://leetcode.com/problems/path-sum/ Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. 题意分析 Input: a binary tree, sum Output: True or False Con…
题目来源 https://leetcode.com/problems/minimum-depth-of-binary-tree/ Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. 题意分析 Input: a binary tree…
题目来源 https://leetcode.com/problems/balanced-binary-tree/ Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never d…
题目来源 https://leetcode.com/problems/binary-tree-level-order-traversal-ii/ Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root). 题意分析 Input: binary tree Output:…
题目来源 https://leetcode.com/problems/maximum-depth-of-binary-tree/ Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. 题意分析 Input: tree Output:…
题目来源 https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/ Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between). 题意分…
题目来源 https://leetcode.com/problems/binary-tree-level-order-traversal/ Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). 题意分析 Input: 一个二叉树 Output:一个每层数值组合的list Conditions:层次遍历 题目思路 采用…
题目来源 https://leetcode.com/problems/symmetric-tree/ Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). 题意分析 Input:一个二叉树 Output:True or False Conditions: 判断一个二叉树是不是对称的 题目思路 一一对应判断值是否相等,注意要清楚谁对应谁. AC代码(Python)…
题目来源 https://leetcode.com/problems/same-tree/ Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurally identical and the nodes have the same value. 题意分析 Input: twon bin…
题目来源 https://leetcode.com/problems/validate-binary-search-tree/ Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left subtree of a node contains only nodes with keys less than the node'…
题目来源 https://leetcode.com/problems/binary-tree-inorder-traversal/ iven a binary tree, return the inorder traversal of its nodes' values. For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,3,2]. 题意分析 Input:tree Output: inorder traversal Cond…
题目来源 https://leetcode.com/problems/restore-ip-addresses/ Given a string containing only digits, restore it by returning all possible valid IP address combinations. For example:Given "25525511135", return ["255.255.11.135", "255.25…
题目来源 https://leetcode.com/problems/reverse-linked-list-ii/ Reverse a linked list from position m to n. Do it in-place and in one-pass. For example:Given 1->2->3->4->5->NULL, m = 2 and n = 4, return 1->4->3->2->5->NULL. Note:G…
题目来源 https://leetcode.com/problems/decode-ways/ A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' -> 1 'B' -> 2 ... 'Z' -> 26 Given an encoded message containing digits, determine the total number…
题目来源 https://leetcode.com/problems/gray-code/ The gray code is a binary numeral system where two successive values differ in only one bit. Given a non-negative integer n representing the total number of bits in the code, print the sequence of gray co…