
Python
文章平均质量分 58
mygodhome
走自己的路,带上自己的猫,让别人去说吧……
展开
-
Shell 和 Python 分别 实现工作组号匹配不重复考场号
#!/bin/bashMatch_GroupID_ClassroomID(){ ExamClassRoom_Start_Num=$1 ExamClassRoom_End_Num=$2 Officer_Start_GroupID=$3 echo " ExamClassRoom_Start_Num is ${ExamClassRoom_Start_Num} ExamClassRoom_End_Num is ${ExamClassRoom_End_Num...原创 2021-06-16 16:04:04 · 170 阅读 · 0 评论 -
Mac 安装Jupyter Notebook和使用Jupyter Notebook
https://blog.youkuaiyun.com/u013983033/article/details/92806650?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522162323004516780357227268%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=162323004516780357227268&转载 2021-06-09 17:19:33 · 530 阅读 · 0 评论 -
PyCharm 2018.2 汉化指南 MAC版
我自己在MAC 上试验过,是可以汉化的。分享一下汉化经验:下载resources_cn.jar :下载地址:https://download.youkuaiyun.com/download/mygodhome/137069121.点击”访达“ --> 选择 ”应用程序“2. 选择 “PyCharm" app :3. 右单击 PyCharm CE, 选择 ”显示包含内容“4.点击 “Contents"目录5. 点击 "lib"目录6. 将下载的 resourc原创 2020-12-16 22:29:49 · 332 阅读 · 0 评论 -
893. Groups of Special-Equivalent Strings
You are given an array A of strings.Two strings S and T are special-equivalent if after any number of moves, S == T.A move consists of choosing two indices i and j with i % 2 == j % 2, and swappin...原创 2018-12-19 22:04:59 · 150 阅读 · 0 评论 -
944. Delete Columns to Make Sorted 【?】
We are given an array A of N lowercase letter strings, all of the same length.Now, we may choose any set of deletion indices, and for each string, we delete all the characters in those indices...原创 2018-12-12 19:38:26 · 140 阅读 · 0 评论 -
832. Flipping(翻转) an Image
Given a binary matrix A, we want to flip the image horizontally, then invert it, and return the resulting image.To flip an image horizontally means that each row of the image is reversed. For ex...原创 2018-12-12 20:35:45 · 228 阅读 · 0 评论 -
461. Hamming Distance
The Hamming distance between two integers is the number of positions at which the corresponding bits are different.Given two integers x and y, calculate the Hamming distance.Note:0 ≤ x, y &...原创 2018-12-12 20:48:17 · 185 阅读 · 0 评论 -
617. Merge Two Binary Trees 【递归调用】
Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not.You need to merge them into a new binary tree...原创 2018-12-12 21:12:42 · 143 阅读 · 0 评论 -
942. DI String Match 越界错误因为空表,索引0不存在
Given a string S that only contains "I" (increase) or "D" (decrease), let N = S.length.Return any permutation A of [0, 1, ..., N] such that for all i = 0, ..., N-1:If S[i] == "I", then A[i] < A...原创 2018-12-12 21:50:23 · 143 阅读 · 0 评论 -
905. Sort Array By Parity
Given an array A of non-negative integers, return an array consisting of all the even(偶数) elements of A, followed by all the odd(奇数) elements of A.You may return any answer array that satisfies this...原创 2018-12-03 21:12:00 · 101 阅读 · 0 评论 -
944. Delete Columns to Make Sorted
We are given an array A of N lowercase letter strings, all of the same length.Now, we may choose any set of deletion indices, and for each string, we delete all the characters in those indices. The...原创 2018-12-04 22:15:50 · 155 阅读 · 0 评论 -
[medium] 6. ZigZag Conversion
The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H NA P L S I I...原创 2018-11-29 21:50:13 · 115 阅读 · 0 评论 -
[Medium] 5. Longest Palindromic Substring
Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.Example 1:Input: "babad"Output: "bab"Note: "aba" is also a valid answer.Exa...原创 2018-11-29 21:48:38 · 99 阅读 · 0 评论 -
[Hard]4. Median of Two Sorted Arrays
There are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).You may assume nums1 and n...原创 2018-11-29 21:44:34 · 110 阅读 · 0 评论 -
[Medium] 3. Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring without repeating characters.Example 1:Input: "abcabcbb"Output: 3 Explanation: The answer is "abc", with the length of 3.Example 2:...原创 2018-11-29 20:16:36 · 117 阅读 · 0 评论 -
[Medium] 2. Add Two Numbers
You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return i...原创 2018-11-29 18:28:40 · 152 阅读 · 0 评论 -
[Easy]1. Two Sum
Given an array of integers, return indices(下标) of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use the s...原创 2018-11-29 18:26:02 · 102 阅读 · 0 评论 -
804. Unique Morse Code Words
International Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes, as follows: "a" maps to ".-", "b" maps to "-...", "c" maps to "-.-.", and so on.F原创 2018-12-02 13:53:28 · 185 阅读 · 0 评论 -
929. Unique Email Addresses and 709. To Lower Case
Every email consists of a local name and a domain name, separated by the @ sign.For example, in alice@leetcode.com, alice is the local name, and leetcode.com is the domain name.Besides lowercase l...原创 2018-12-02 11:25:03 · 425 阅读 · 0 评论 -
717. 1-bit and 2-bit Characters
We have two special characters. The first character can be represented by one bit 0. The second character can be represented by two bits (10 or 11).Now given a string represented by several bits. Re...原创 2018-12-13 21:29:34 · 125 阅读 · 0 评论 -
258. Add Digits 【递归】
Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.Example:Input: 38Output: 2 Explanation: The process is like: 3 + 8 = 11, 1 + 1 = 2. ...原创 2018-12-13 22:15:48 · 107 阅读 · 0 评论 -
67. Add Binary 二进制转换10进制加法再转换回去
Given two binary strings, return their sum (also a binary string).The input strings are both non-empty and contains only characters 1 or 0.Example 1:Input: a = "11", b = "1"Output: "100"E...原创 2018-12-13 22:34:15 · 181 阅读 · 0 评论 -
884. Uncommon Words from Two Sentences 用collections模块里的Counter类对象计数,返回字典中的key
We are given two sentences A and B. (A sentence is a string of space separated words. Each wordconsists only of lowercase letters.)A word is uncommon if it appears exactly once in one of the sente...原创 2018-12-25 23:21:16 · 174 阅读 · 0 评论 -
961. N-Repeated Element in Size 2N Array 集合+求和减法
In a array A of size 2N, there are N+1 unique elements, and exactly one of these elements is repeated N times.Return the element repeated N times. Example 1:Input: [1,2,3,3]Output: 3Examp...原创 2018-12-25 22:24:03 · 136 阅读 · 0 评论 -
541. Reverse String II
Given a string and an integer k, you need to reverse the first k characters for every 2k characters counting from the start of the string. If there are less than k characters left, reverse all of them...原创 2018-12-30 21:24:18 · 141 阅读 · 0 评论 -
917. Reverse Only Letters :先逆序再插入 c.isalpha() and reversed(String)
Given a string S, return the "reversed" string where all characters that are not a letter stay in the same place, and all letters reverse their positions. Example 1:Input: "ab-cd"Output: "dc-b...原创 2018-12-30 19:33:34 · 281 阅读 · 0 评论 -
953. Verifying an Alien Dictionary
In an alien language, surprisingly they also use english lowercase letters, but possibly in a different order. The order of the alphabet is some permutation of lowercase letters.Given a sequence ...原创 2018-12-30 14:19:48 · 356 阅读 · 0 评论 -
371. Sum of Two Integers 负数不行 ?
Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -.Example 1:Input: a = 1, b = 2Output: 3Example 2:Input: a = -2, b = 3Output: 1 cl...原创 2018-12-30 13:52:38 · 273 阅读 · 0 评论 -
118. Pascal's triangle out of range
Given a non-negative integer numRows, generate the first numRows of Pascal's triangle.In Pascal's triangle, each number is the sum of the two numbers directly above it.Example:Input: 5Output:...原创 2018-12-11 22:09:38 · 158 阅读 · 0 评论 -
122. Best Time to Buy and Sell Stock II 超时解决
Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (i.e., buy...原创 2018-12-11 20:21:16 · 136 阅读 · 0 评论 -
868. Binary Gap
Given a positive integer N, find and return the longest distance between two consecutive 1's in the binary representation of N.If there aren't two consecutive 1's, return 0. Example 1:...原创 2018-12-16 20:00:01 · 133 阅读 · 0 评论 -
389. Find the Difference 用list的方法strip()隔断字符串判断list长度来确定差别字符
Given two strings s and t which consist of only lowercase letters.String t is generated by random shuffling string s and then add one more letter at a random position.Find the letter that was adde...原创 2018-12-26 22:49:37 · 151 阅读 · 0 评论 -
13. Roman to Integer
Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.Symbol ValueI 1V 5X 10L 50C 100D ...原创 2018-12-26 22:17:34 · 93 阅读 · 0 评论 -
557. Reverse Words in a String III 去掉字符串首尾空格方法object.strip()
Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.Example 1:Input: "Let's take LeetCode contest"...原创 2018-12-26 21:31:52 · 179 阅读 · 0 评论 -
922. Sort Array By Parity II
Given an array A of non-negative integers, half of the integers in A are odd, and half of the integers are even.Sort the array so that whenever A[i] is odd, i is odd; and whenever A[i] is even, i...原创 2018-12-15 22:27:49 · 126 阅读 · 0 评论 -
728. Self Dividing Numbers [for ...else]
A self-dividing number is a number that is divisible by every digit it contains.For example, 128 is a self-dividing number because 128 % 1 == 0, 128 % 2 == 0, and 128 % 8 == 0.Also, a self-divi...原创 2018-12-15 20:58:59 · 152 阅读 · 0 评论 -
20. Valid Parentheses
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.An input string is valid if:Open brackets must be closed by the same type o...原创 2018-12-13 23:46:46 · 94 阅读 · 0 评论 -
771. Jewels and Stones
You're given strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in S is a type of stone you have. You want to know how many of the sto...原创 2018-12-02 10:04:01 · 130 阅读 · 0 评论 -
Python3将一个文件夹备份到一个 ZIP 文件
题目:将一个文件夹备份到一个 ZIP 文件假定你正在做一个项目,它的文件保存在 C:\AlsPythonBook 文件夹中。你担心工作 会丢失,所以希望为整个文件夹创建一个 ZIP 文件,作为“快照”。你希望保存不同的版 本,希望 ZIP 文件的文件名每次创建时都有所变化。例如 AlsPythonBook_1.zip、 AlsPythonBook_2.zip、AlsPythonBook_3.z...原创 2018-11-05 20:01:05 · 358 阅读 · 0 评论 -
Python3:将带有美国风格日期的文件改名为欧洲风格日期
假定你的老板用电子邮件发给你上千个文件,文件名包含美国风格的日期 (MM-DD-YYYY),需要将它们改名为欧洲风格的日期(DD-MM-YYYY)。手工完成这个无聊的任务可能需要几天时间!让我们写一个程序来完成它。下面是程序要做的事:检查当前工作目录的所有文件名,寻找美国风格的日期。如果找到,将该文件改名,交换月份和日期的位置,使之成为欧洲风格。 这意味着代码需要做下面的事情:创建...原创 2018-10-31 19:34:27 · 570 阅读 · 0 评论