摘要:
Given an array of strings, group anagrams together. Example: Note: All inputs will be in lowercase. The order of your output does not matter. 题目思路为利用c 阅读全文
随笔档案-2018年06月
[Leetcode] 336. Palindrome Pairs_Hard
2018-06-21 06:13 by Johnson_强生仔仔, 253 阅读, 收藏, 编辑
摘要:
Given a list of unique words, find all pairs of distinct indices (i, j) in the given list, so that the concatenation of the two words, i.e. words[i] + 阅读全文
[LeetCode] 560. Subarray Sum Equals K_Medium
2018-06-21 05:39 by Johnson_强生仔仔, 230 阅读, 收藏, 编辑
摘要:
Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k. Example 1: Note: 这个题目思路是 阅读全文
[LeetCode] Template to N Sum for (LC 15. 3Sum, LC 18. 4Sum)(N>2)
2018-06-21 04:56 by Johnson_强生仔仔, 266 阅读, 收藏, 编辑
摘要:
思路为将N sum 转换为N-1 Sum, 直到转换为 2 Sum. 不过最开始就已经将nums sort一下, 然后再处理. 阅读全文
[LeetCode] 1. Two Sum_Easy
2018-06-21 04:28 by Johnson_强生仔仔, 168 阅读, 收藏, 编辑
摘要:
Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have ex 阅读全文
[Leetcode] Template to rotate matrix
2018-06-18 10:57 by Johnson_强生仔仔, 303 阅读, 收藏, 编辑
摘要:
Rotate the image by 90 degrees (clockwise). [[1,2,3,4], [[9,10,11,12], [[9,5,1], [5,6,7,8], ==> [5,6,7,8], ==> [10,6,2], [9,10,11,12]] [1,2,3,4]] [11, 阅读全文
[LeetCode] Backtracking Template for (Subsets, Permutations, and Combination Sum)
2018-06-18 03:44 by Johnson_强生仔仔, 381 阅读, 收藏, 编辑
摘要:
根据issac3 用Java总结了backtracking template, 我用他的方法改成了Python. 以下为template. 可以用来解决的问题有: Leetcode 78. Subsets , Leetcode 90. Subsets II, Leetcode 46. Permuta 阅读全文
[LeetCode] 209. Minimum Size Subarray Sum_Medium
2018-06-16 03:00 by Johnson_强生仔仔, 179 阅读, 收藏, 编辑
摘要:
Given an array of n positive integers and a positive integer s, find the minimal length of a contiguous subarray of which the sum ≥ s. If there isn't 阅读全文