代码改变世界

[LeetCode] 690. Employee Importance_Easy tag: BFS

2018-07-02 23:08 by Johnson_强生仔仔, 200 阅读, 0 推荐, 收藏, 编辑
摘要:You are given a data structure of employee information, which includes the employee's unique id, his importance value and his directsubordinates' id. 阅读全文

[LeetCode] 733. Flood Fill_Easy tag: BFS

2018-07-02 11:05 by Johnson_强生仔仔, 329 阅读, 0 推荐, 收藏, 编辑
摘要:An image is represented by a 2-D array of integers, each integer representing the pixel value of the image (from 0 to 65535). Given a coordinate (sr, 阅读全文

[Leetcode] 49. Group Anagrams_Medium

2018-06-21 07:07 by Johnson_强生仔仔, 153 阅读, 0 推荐, 收藏, 编辑
摘要: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 阅读全文

[Leetcode] 336. Palindrome Pairs_Hard

2018-06-21 06:13 by Johnson_强生仔仔, 252 阅读, 0 推荐, 收藏, 编辑
摘要: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_强生仔仔, 228 阅读, 0 推荐, 收藏, 编辑
摘要: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_强生仔仔, 264 阅读, 0 推荐, 收藏, 编辑
摘要:思路为将N sum 转换为N-1 Sum, 直到转换为 2 Sum. 不过最开始就已经将nums sort一下, 然后再处理. 阅读全文

[LeetCode] 1. Two Sum_Easy

2018-06-21 04:28 by Johnson_强生仔仔, 168 阅读, 0 推荐, 收藏, 编辑
摘要: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_强生仔仔, 299 阅读, 0 推荐, 收藏, 编辑
摘要: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_强生仔仔, 379 阅读, 0 推荐, 收藏, 编辑
摘要:根据issac3 用Java总结了backtracking template, a56爆大奖在线娱乐用他的方法改成了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_强生仔仔, 177 阅读, 0 推荐, 收藏, 编辑
摘要: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 阅读全文
上一页 1 ··· 35 36 37 38 39