前进 达瓦里希
jiangshanmeta / meta Goto Github PK
View Code? Open in Web Editor NEWleetcode javascript/typescript实现
License: MIT License
leetcode javascript/typescript实现
License: MIT License
900-999 934 939 940 947 954
800-899 802 834 846
700-799 762 775 710 738
200-299
class Solution:
def twoSum(self, numbers, target):
tmp = []
for i in numbers:
tmp.append(i)
numbers = sorted(numbers)
a = 0
b = len(numbers) - 1
while True:
if numbers[a] + numbers[b] == target:
break
elif numbers[a] + numbers[b] < target:
a += 1
elif numbers[a] + numbers[b] > target:
b -= 1
reta = numbers[a]
retb = numbers[b]
a = -1
b = -1
for i in range(0, len(tmp)):
if tmp[i] == reta and a == -1:
a = i
elif tmp[i] == retb and b == -1:
b = i
if a > b:
a = a ^ b
b = a ^ b
a = a ^ b
return [a, b]
nums=[-1,-2,-3,-4,-5]
target=-8
so=Solution()
print(so.twoSum(nums,target))
38
58
541 Reverse String II 然而和344无关 按照题目做就好了
151 Reverse Words in a String 按照题目做就好了
557 Reverse Words in a String III 按照题目做就好了
434 Number of Segments in a String
273 Integer to English Words 最无聊的hard题 hash
383 Ransom Note 按字符计数
520 Detect Capital 按照题目做就好了
709 实现 toLowerCase
551 student-attendance-record-i 按照题目做就好了
387 First Unique Character in a String 按照题目做就好了 用个hash也没啥吧
438 find-all-anagrams-in-a-string hash 可以说两句 这题有点意思
567 Permutation in String(和438一个思路)
767 Reorganize String
521 Longest Uncommon Subsequence I 脑筋急转弯
522 Longest Uncommon Subsequence II (521的衍生 还算有点意思)
833 Find And Replace in String 按照题目说的做 无聊
809 expressive-words 按照题目说的做 无聊
43 Multiply Strings
726 Number of Atoms
722 Remove Comments 无聊
1023 Camelcase Matching 有点意思
1002 Find Common Characters
1003 Check If Word Is Valid After Substitutions
916 Word Subsets 有点意思
925 Long Pressed Name
929 Unique Email Addresses
937 Reorder Log Files
859 Buddy Strings
816 Ambiguous Coordinates
824 Goat Latin 无聊
831 Masking Personal Information
848 Shifting Letters
777 Swap Adjacent in LR String
796 Rotate String
640 Solve the Equation
678 Valid Parenthesis String
680 Valid Palindrome II
686 Repeated String Match
696 Count Binary Substrings
556 Next Greater Element III
409 Longest Palindrome
443 String Compression
459 Repeated Substring Pattern
468 Validate IP Address
482 License Key Formatting
385 Mini Parser
1071 Greatest Common Divisor of Strings
1096 (类似385 726)
1106 (类似1096)
165
28
1180
1108 水题
1119 水题
1160 水题
1190 parse
125 Valid Palindrome 判断是否是回文
344 Reverse String 翻转字符串
345 Reverse Vowels of a String 翻转字符串
917 翻转字符串
209 Minimum Size Subarray Sum
905 Sort Array By Parity
922 Sort Array By Parity II
838 Push Dominoes
713 Subarray Product Less Than K
228 Summary Ranges
80
653(2sum 入参为BST)
605
168 转换为26进制
171 26进制转换为10进制
504 进制转换7
1017 Convert to Base -2
405 Convert a Number to Hexadecimal 转换为16进制
12
13
592 Fraction Addition and Subtraction
908 smallest-range-i
914 X of a Kind in a Deck of Cards 需要求最大公约数
869 Reordered Power of 2
883 Projection Area of 3D Shapes
892 Surface Area of 3D Shapes
166 Fraction to Recurring Decimal
807 Max Increase to Keep City Skyline
812 Largest Triangle Area
836 Rectangle Overlap
781 Rabbits in Forest
789 Escape The Ghosts
794 Valid Tic-Tac-Toe State (无聊)
628 Maximum Product of Three Numbers
633 Sum of Square Numbers
670 Maximum Swap
1041 Robot Bounded In Circle
1037 Valid Boomerang
507 Perfect Number
537 Complex Number Multiplication
539 Minimum Time Difference
593 Valid Square
598 Range Addition II
400 Nth Digit
414 Third Maximum Number
415 Add Strings
423 Reconstruct Original Digits from English
441 Arranging Coins
492 Construct the Rectangle
319 Bulb Switcher
357 Count Numbers with Unique Digits
367 判断是否是平方数
396 Rotate Function
397 Integer Replacement
202 Happy Number
223 Rectangle Area
258 Add Digits
263 Ugly Number
1093 统计
172 Factorial Trailing Zeroes
69 sqrt
67 二进制数字相加
66 +1
65 判断是否是数字
29
1103
1131 绝对值
204 质数
1175 质数
1185 日期
1232 看点是否在一条直线上
3 Longest Substring Without Repeating Characters
239 Sliding Window Maximum 划重点
480 Sliding Window Median 滑动窗口+二分
1004 Max Consecutive Ones III
1031 Maximum Sum of Two Non-Overlapping Subarrays 划重点
643 Maximum Average Subarray I
1052 Grumpy Bookstore Owner
1100 Find K-Length Substrings With No Repeated Characters
1176
1208
a^b^b = a^0 = a 即利用异或可以成对消去重复元素
相关题目: 389
318 Maximum Product of Word Lengths
1009 Complement of Base 10 Integer &取数字二进制最后一位 << 乘2 >> 除2
868 >>除2 &获取二进制最后一位
693 Binary Number with Alternating Bits &获取二进制最后一位
461 Hamming Distance
476 Number Complement
477
338 Counting Bits 右移 &
371 位运算实现加法
201
260 (^ a^b^b=a)
136 xor
190 &取数字二进制最后一位 左移 右移
191
397
762(求连续数二进制1的个数)
1239 利用32位表示用过的字符 有点意思
861 Score After Flipping Matrix
867 矩阵的转置
885 Spiral Matrix III 螺旋遍历矩阵
832 Flipping an Image
840 Magic Squares In Grid
766 Toeplitz Matrix
1034 Coloring A Border (DFS)
661 Image Smoother
529 Minesweeper (DFS)
566 Reshape the Matrix
419 Battleships in a Board
463 Island Perimeter
498 Diagonal Traverse
240 Search a 2D Matrix II
289 Game of Life
1091 Shortest Path in Binary Matrix (BFS)
130 Surrounded Regions (DFS BFS)
73
59 螺旋遍历矩阵
54 螺旋遍历矩阵
48 Rotate Image
1139 Largest 1-Bordered Square
695(dfs)
200(dfs)
733(dfs)
547(图连通分量的个数)
378
1162 BFS
959 DFS
1222 一个点向各个方向探查
1252 不太好分类
1254 DFS
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.