what??
去追啊
这个作者很懒,什么都没留下…
展开
-
1043 What's In A Name?
orz,我真的不知道哪里出错了,,,今天状态不是很好,就这一道题都没做完#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>using namespace std;char id[ 20 ][ 20 ];char name[ 20 ][ 20 ]...原创 2018-09-11 17:40:08 · 326 阅读 · 0 评论 -
8. String to Integer (atoi)
题解中的最高赞答案:re.findall() 正则表达式用法星号 * :解包作用lstrip 方法:自己根据题解的实现:( python2 也是可以实现的 )class Solution(object): def myAtoi(self, str): """ :type str: str :rtype:...原创 2019-10-07 23:36:46 · 84 阅读 · 0 评论 -
4. Median of Two Sorted Arrays
根据题解里面的一个思路写的,啊 感觉 困难 等级的题,好难做==,代码也好难写有许多需要注意的点:最精妙的就是 利用二分法 找两数组的中间位置: m1 = left + (right - left) // 2 m2 = k - m1 if nums1[m1] < nums2[m2 - 1]: ...原创 2019-07-22 10:48:28 · 82 阅读 · 0 评论 -
858. Mirror Reflection
图摘自题目的discussion高赞答案,第二张图是解释class Solution { public int mirrorReflection(int p, int q) { while( p % 2 == 0 && q % 2 == 0 ){ p /= 2; q /= 2; ...原创 2019-03-30 09:50:30 · 124 阅读 · 0 评论 -
748. Shortest Completing Word
很巧妙啊,,用素数乘积能否被整除来表征是否可以将字符全部包含class Solution { private static final int[] prime = { 2 , 3 , 5 , 7 , 11 , 13 , 17 , 19 , 23 , 29 , 31 , 37 , 41 , 43 , 47 , 53 , 59 , 61 , 67 , 71 , 73 , 79 , 83...原创 2018-09-28 22:49:37 · 97 阅读 · 0 评论 -
258. Add Digits
同余公式 dr( n ) = 1 + ( n - 1 ) % 9 digit rootclass Solution { public int addDigits(int num) { return 1 + ( num - 1 ) % 9 ; }}原创 2018-09-28 22:11:34 · 75 阅读 · 0 评论 -
638. Shopping Offers
为什么会堆栈溢出啊,哭唧唧,没找到问题== class Solution { public int shoppingOffers(List<Integer> price, List<List<Integer>> special, List<Integer> needs) { return helper( price , ...原创 2018-09-16 08:08:15 · 103 阅读 · 0 评论 -
350. Intersection of Two Arrays II
class Solution { public int[] intersect(int[] nums1, int[] nums2) { Map<Integer,Integer> hash1 = new HashMap<>(); ArrayList<Integer> res = new ArrayList<>(...原创 2018-09-15 22:40:31 · 96 阅读 · 0 评论 -
765. Couples Holding Hands
emmm,似懂非懂。。class Solution { private void swap(int[] arr , int x , int y ){ int tmp = arr[ x ]; arr[ x ] = arr[ y ]; arr[ y ] = tmp; } public int minSwapsCouples(...原创 2018-09-15 22:05:15 · 110 阅读 · 0 评论 -
856. Score of Parentheses
括号匹配,按照运算规则计算,不会,,,看了discussion还是不太会诺。。。vector没有初始化的话会出很多错误!!!Approach1:class Solution {public: int scoreOfParentheses(string S) { vector<int> res( 30 , 0 ); int l = ...原创 2018-09-05 16:04:53 · 106 阅读 · 0 评论 -
421. Maximum XOR of Two Numbers in an Array
https://leetcode-cn.com/problems/maximum-xor-of-two-numbers-in-an-array/solution/li-yong-yi-huo-yun-suan-de-xing-zhi-tan-xin-suan-f/两个数相同位置上1、0不同的位数越多,且越靠近高位,最后的结果越大1. 异或运算就是二进制下不应用进位的加法2. 如果...原创 2019-10-09 15:16:36 · 109 阅读 · 0 评论