代码 class Solution: def sumZero(self, n: int) -> List[int]: positive = n // 2 negative = n // 2 addzero = 0 if positive + negative == n - 1: addzero = 1 pos = [i for i in range(1, positive+1)] neg = [-i for i in range(1, negative+1)] if addzero: return pos...
代码 class Solution: def largestUniqueNumber(self, A: List[int]) -> int: dic = {} for i in A: if i not in dic: dic[i] = 1 else: dic[i] += 1 maxnum = -1 for key in dic.keys(): if dic[key] == 1: maxnum = max(maxnum, key) return maxnum 分类: LeetCode 标签...
FindHeaderBarSize FindTabBarSize Given an array of integersarr, returntrueif the number of occurrences of each value in the array isuniqueorfalseotherwise. Example 1: Input:arr = [1,2,2,1,1,3]Output:trueExplanation:The value 1 has 3 occurrences, 2 has 2 and 3 has 1. No two values ...
0378. Kth Smallest Element in a Sorted Matrix 0382. Linked List Random Node 0383. Ransom Note 0384. Shuffle an Array 0385. Mini Parser 0386. Lexicographical Numbers 0387. First Unique Character in a String 0389. Find the Difference 0390. Elimination Game 0391. Perfect Rectangle 0392. Is...
0025. Reverse Nodes in K Group 0026. Remove Duplicates From Sorted Array 0027. Remove Element 0028. Find the Index of the First Occurrence in a String 0029. Divide Two Integers 0030. Substring With Concatenation of All Words 0031. Next Permutation 0032. Longest Valid Parentheses 0033. Search...
【leetcode】1289. Minimum Falling Path Sum II 2019-12-15 09:10 −题目如下: Given a square grid of integers arr, a falling path with non-zero shifts is a choice of exactly one element from each r... seyjs 0 576 LeetCode 1292. Maximum Side Length of a Square with Sum Less than ...
Vue + Element UI (table) 2019-12-06 13:26 −<el-table-column prop="type" header-align="center" align="center" sortable label="轮播图类型"> <template slot-scope="scope"> &l... 小兔子09 0 5108 [Algorithm] 387. First Unique Character in a String ...
publicint[]sumZero(intn){int[] A =newint[n];for(inti =0; i < n; ++i) A[i] = i *2- n +1;returnA; } 这个solution是通过找对称性规律直接在Array[i]里赋相反值达到的效果 评论里提出我的代码n==2时返回的数组是{0,0},这违反了题目中的一致性。
Notes: 2. Examples: 3.Solutions: 1/**2* Created by sheepcore on 2019-02-243*/4classSolution {5publicintuniqueMorseRepresentations(String[] strs) {6charch;//current char of eace word7String morse = "";//morsecode for each word8Set morseSet =newHashSet();//used for containing morse...
LeetCode 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....