[LeetCode] 1512. Number of Good Pairs Given an array of integers nums, return the number of good pairs. A pair (i, j) is called good if nums[i] == nums[j] and i < j. Example 1:Input: nums = [1,2,3,1,1,3]Output: 4Explanat 2020-07-13 #leetcode #array #hashmap #java #math
[LeetCode] 763. Partition Labels You are given a string s. We want to partition the string into as many parts as possible so that each letter appears in at most one part. Note that the partition is done so that after concatenating al 2020-07-10 #leetcode #two pointer #hashmap #java #greedy #string
[LeetCode] 1503. Last Moment Before All Ants Fall Out of a Plank We have a wooden plank of the length n units. Some ants are walking on the plank, each ant moves with speed 1 unit per second. Some of the ants move to the left, the other move to the right. When two 2020-07-05 #leetcode #array #java #javascript #brainteaser
[LeetCode] 271. Encode and Decode Strings Design an algorithm to encode a list of strings to a string. The encoded string is then sent over the network and is decoded back to the original list of strings. Machine 1 (sender) has the function: 2020-07-05 #leetcode #java #javascript #string #design
[LeetCode] 38. Count and Say The count-and-say sequence is a sequence of digit strings defined by the recursive formula:countAndSay(1) = “1”countAndSay(n) is the way you would “say” the digit string from countAndSay(n-1), wh 2020-07-04 #leetcode #java #string #simulation
[LeetCode] 279. Perfect Squares Given an integer n, return the least number of perfect square numbers that sum to n. A perfect square is an integer that is the square of an integer; in other words, it is the product of some integer 2020-06-28 #leetcode #java #javascript #dynamic programming #math #knapsack
[LeetCode] 1014. Best Sightseeing Pair You are given an integer array values where values[i] represents the value of the ith sightseeing spot. Two sightseeing spots i and j have a distance j - i between them. The score of a pair (i < j) 2020-06-17 #leetcode #array #java #dynamic programming #greedy
[LeetCode] 392. Is Subsequence Given two strings s and t, return true if s is a subsequence of t, or false otherwise. A subsequence of a string is a new string that is formed from the original string by deleting some (can be none) 2020-06-10 #leetcode #two pointer #java #dynamic programming #greedy #binary search
[LeetCode] 259. 3Sum Smaller Given an array of n integers nums and an integer target, find the number of index triplets i, j, k with 0 <= i < j < k < n that satisfy the condition nums[i] + nums[j] + nums[k] < 2020-05-28 #leetcode #array #two pointer #java #sort
[LeetCode] 394. Decode String Given an encoded string, return its decoded string. The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. Note that k is guara 2020-05-28 #leetcode #java #string #stack #recursion #javacript