![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetCode
sa酱
这个作者很懒,什么都没留下…
展开
-
1952. Three Divisors 三除数
Given an integern, returntrueifnhasexactly three positive divisors. Otherwise, returnfalse.An integermis adivisorofnif there exists an integerksuch thatn = k * m.Example 1:Input: n = 2Output: falseExplantion: 2 has only two divis...原创 2022-04-24 17:25:09 · 352 阅读 · 0 评论 -
2016. Maximum Difference Between Increasing Elements增量元素之间的最大差值
Given a0-indexedinteger arraynumsof sizen, find themaximum differencebetweennums[i]andnums[j](i.e.,nums[j] - nums[i]), such that0 <= i < j < nandnums[i] < nums[j].Returnthemaximum difference.If no suchiandjexists, return...原创 2022-04-24 16:46:47 · 335 阅读 · 0 评论 -
718. Maximum Length of Repeated Subarray【最大公共子数组】
其实这个数组换成字符串来看也是一样的Given two integer arraysnums1andnums2, returnthe maximum length of a subarray that appears inbotharrays.Example 1:Input: nums1 = [1,2,3,2,1], nums2 = [3,2,1,4,7]Output: 3Explanation: The repeated subarray with maximum len...原创 2022-04-24 16:26:53 · 246 阅读 · 0 评论 -
最长公共子序列1143. Longest Common Subsequence
昨天笔试题里看到了,其实有一点点区别,不过这个似乎更难一点。先做了。Given two stringstext1andtext2, returnthe length of their longestcommon subsequence.If there is nocommon subsequence, return0.Asubsequenceof a string is a new string generated from the original string with so...原创 2022-04-21 17:12:29 · 140 阅读 · 0 评论 -
1446. Consecutive Characters JavaScript解法
Thepowerof the string is the maximum length of a non-empty substring that contains only one unique character.Given a strings, returnthepowerofs.Example 1:Input: s = "leetcode"Output: 2Explanation: The substring "ee" is of length 2 with th...原创 2022-04-12 17:11:04 · 800 阅读 · 0 评论 -
【LeetCode】496. Next Greater Element I
You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nums1's elements in the corresponding places of原创 2017-08-01 10:42:59 · 221 阅读 · 0 评论 -
【LeetCode】654. Maximum Binary Tree
Given an integer array with no duplicates. A maximum tree building on this array is defined as follow:The root is the maximum number in the array.The left subtree is the maximum tree constructed f原创 2017-08-08 14:37:55 · 317 阅读 · 0 评论 -
【LeetCode】647. Palindromic Substrings
Given a string, your task is to count how many palindromic substrings in this string.The substrings with different start indexes or end indexes are counted as different substrings even they consis原创 2017-08-11 10:07:48 · 396 阅读 · 0 评论 -
【LeetCode】513. Find Bottom Left Tree Value
Given a binary tree, find the leftmost value in the last row of the tree.Example 1:Input: 2 / \ 1 3Output:1Example 2: Input: 1 / \ 2 3原创 2017-08-11 11:44:21 · 230 阅读 · 0 评论 -
【LeetCode】442. Find All Duplicates in an Array
Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements that appear twice in this array.Could you do it without ex原创 2017-08-15 15:33:09 · 221 阅读 · 0 评论 -
【LeetCode】657.Judge Route Circle
Initially, there is a Robot at position (0, 0). Given a sequence of its moves, judge if this robot makes a circle, which means it moves back to the original place.The move sequence is represented原创 2017-11-22 14:36:16 · 204 阅读 · 0 评论 -
【LeetCode】728. Self Dividing Numbers
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-d原创 2017-11-23 10:12:57 · 339 阅读 · 0 评论 -
【LeetCode】682. Baseball Game
You're now a baseball game point recorder.Given a list of strings, each string can be one of the 4 following types:Integer (one round's score): Directly represents the number of points you g原创 2017-11-24 14:56:19 · 234 阅读 · 0 评论 -
【LeetCode】463. Island Perimeter
You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water. Grid cells are connected horizontally/vertically (not diagonally). The grid is completely原创 2017-08-01 09:53:13 · 196 阅读 · 0 评论 -
【LeetCode】637. Average of Levels in Binary Tree
Given a non-empty binary tree, return the average value of the nodes on each level in the form of an array.Example 1:Input: 3 / \ 9 20 / \ 15 7Output: [3, 14.5, 11]Explan原创 2017-07-31 16:30:16 · 390 阅读 · 0 评论 -
【LeetCode】575. Distribute Candies
哇,这么题!!虽然写的是easy!但是我!!!用了三种方法才过!Given an integer array with even length, where different numbers in this array represent different kinds of candies. Each number means one candy of the correspo原创 2017-07-21 14:23:15 · 397 阅读 · 0 评论 -
【leetCode】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,原创 2017-07-20 12:01:50 · 169 阅读 · 0 评论 -
【LeetCode】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 tr原创 2017-07-20 14:14:36 · 233 阅读 · 0 评论 -
【LeetCode】595. Big Countries
这是属于MySQL的知识,本来是不属于前端范畴的。但是想了一下想看看自己大学的知识是不是都还给老师了,所以试了一下。异常简单的一个问题啊。There is a table World+-----------------+------------+------------+--------------+---------------+| name原创 2017-07-20 14:17:55 · 542 阅读 · 0 评论 -
【LeetCode】561. Array Partition I
Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), ..., (an, bn) which makes sum of min(ai, bi) for all i from 1 to n as large a原创 2017-07-20 14:25:27 · 355 阅读 · 0 评论 -
【LeetCode】537. Complex Number Multiplication
复数乘法的问题i的平方=-1;Given two strings representing two complex numbers.You need to return a string representing their multiplication. Note i2 = -1 according to the definition.Example 1:原创 2017-07-20 14:27:42 · 221 阅读 · 0 评论 -
【LeetCode】419. Battleships in a Board
Given an 2D board, count how many battleships are in it. The battleships are represented with 'X's, empty slots are represented with '.'s. You may assume the following rules:You receive a valid原创 2017-07-20 14:33:15 · 240 阅读 · 0 评论 -
【LeetCode】 476. Number Complement
Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation.Note:The given integer is guaranteed to fit within the range原创 2017-07-20 14:54:29 · 252 阅读 · 0 评论 -
【LeetCode】627. Swap Salary
Given a table salary, such as the one below, that has m=male and f=female values. Swap all f and m values (i.e., change all f values to m and vice versa) with a single update query and no intermedia原创 2017-07-20 14:59:58 · 1862 阅读 · 0 评论 -
【LeetCode】338. Counting Bits
Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary representation and return them as an array.Example:For num = 5 y原创 2017-07-21 09:01:48 · 367 阅读 · 0 评论 -
【LeetCode】500. Keyboard Row
Given a List of words, return the words that can be typed using letters of alphabet on only one row's of American keyboard like the image below.Example 1:Input: ["Hello", "Alaska", "Da原创 2017-07-21 09:04:13 · 251 阅读 · 0 评论 -
【LeetCode】557. Reverse Words in a String III
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 contes原创 2017-07-21 09:07:03 · 356 阅读 · 0 评论 -
【LeetCode】566. Reshape the Matrix
In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new one with different size but keep its original data.You're given a matrix represented by a two-dimen原创 2017-07-21 10:03:20 · 327 阅读 · 0 评论 -
【LeetCode】535. Encode and Decode TinyURL
最近没什么事。。决定开始刷LeetCode。找点自信,决定由AC率从高往低刷。开始!Note: This is a companion problem to the System Design problem: Design TinyURL.TinyURL is a URL shortening service where you enter a URL suc原创 2017-07-20 11:40:58 · 346 阅读 · 0 评论