2018年7月19日

101. Symmetric Tree

摘要: Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree [1,2,2,3,4,4,3] is symmet 阅读全文

posted @ 2018-07-19 12:18 猪猪🐷 阅读(85) 评论(0) 推荐(0)

563. Binary Tree Tilt

摘要: Given a binary tree, return the tilt of the whole tree. The tilt of a tree node is defined as the absolute difference between the sum of all left subt 阅读全文

posted @ 2018-07-19 12:17 猪猪🐷 阅读(72) 评论(0) 推荐(0)

508. Most Frequent Subtree Sum

摘要: Given the root of a tree, you are asked to find the most frequent subtree sum. The subtree sum of a node is defined as the sum of all the node values 阅读全文

posted @ 2018-07-19 12:16 猪猪🐷 阅读(112) 评论(0) 推荐(0)

543. Diameter of Binary Tree

摘要: Time Complexity: O(N) We visit every node once. Space Complexity: O(N), the size of our implicit call stack during our depth-first search. Time Comple 阅读全文

posted @ 2018-07-19 12:08 猪猪🐷 阅读(71) 评论(0) 推荐(0)

100. Same Tree

摘要: Given two binary trees, write a function to check if they are the same or not. Two binary trees are considered the same if they are structurally ident 阅读全文

posted @ 2018-07-19 12:05 猪猪🐷 阅读(98) 评论(0) 推荐(0)

250. Count Univalue Subtrees (A Uni-value subtree means all nodes of the subtree have the same value.)

摘要: Given a binary tree, count the number of uni-value subtrees. A Uni-value subtree means all nodes of the subtree have the same value. Example : 阅读全文

posted @ 2018-07-19 12:05 猪猪🐷 阅读(109) 评论(0) 推荐(0)

226. Invert Binary Tree

摘要: Invert a binary tree. Example: Input: Output: 阅读全文

posted @ 2018-07-19 12:04 猪猪🐷 阅读(83) 评论(0) 推荐(0)

2018年7月18日

161. One Edit Distance

摘要: Given two strings s and t, determine if they are both one edit distance apart. Note: There are 3 possiblities to satisify one edit distance apart: Exa 阅读全文

posted @ 2018-07-18 13:16 猪猪🐷 阅读(85) 评论(0) 推荐(0)

20. Valid Parentheses

摘要: Three pairs {} [] () If we see {, we push } into the stack If we see [, we push ] into the stack If we see (, we push ) into the stack If we see curre 阅读全文

posted @ 2018-07-18 13:10 猪猪🐷 阅读(103) 评论(0) 推荐(0)

71. Simplify Path

摘要: “..” Means go up a level, so delete the prev “.” Means do nothing “” Means do nothing First, we need to split the input by the splitter “/” 这种方式Arrays 阅读全文

posted @ 2018-07-18 13:07 猪猪🐷 阅读(118) 评论(0) 推荐(0)

311. Sparse Matrix Multiplication

摘要: class Solution { public int[][] multiply(int[][] A, int[][] B) { int m = A.length; int n = A[0].length; int nB = B[0].length; int[][] C = new int[m][nB]; for(... 阅读全文

posted @ 2018-07-18 12:54 猪猪🐷 阅读(99) 评论(0) 推荐(0)

554. Brick Wall

摘要: There is a brick wall in front of you. The wall is rectangular and has several rows of bricks. The bricks have the same height but different width. Yo 阅读全文

posted @ 2018-07-18 12:52 猪猪🐷 阅读(87) 评论(0) 推荐(0)

252. Meeting Rooms

摘要: /** * Definition for an interval. * public class Interval { * int start; * int end; * Interval() { start = 0; end = 0; } * Interval(int s, int e) { st 阅读全文

posted @ 2018-07-18 12:45 猪猪🐷 阅读(131) 评论(0) 推荐(0)

345. Reverse Vowels of a String

摘要: Write a function that takes a string as input and reverse only the vowels of a string. Example 1: Example 2: Input: "leetcode" Output: "leotcede" Exam 阅读全文

posted @ 2018-07-18 09:53 猪猪🐷 阅读(89) 评论(0) 推荐(0)

344. Reverse String

摘要: Write a function that takes a string as input and returns the string reversed. Example 1: Input: "hello" Output: "olleh" Example 2: Input: "A man, a p 阅读全文

posted @ 2018-07-18 09:47 猪猪🐷 阅读(87) 评论(0) 推荐(0)

415. Add Strings

摘要: This one is very similar to add binary , pretty much the same The only difference is % 10, /10 When the two strings are exhausted, need to check if th 阅读全文

posted @ 2018-07-18 09:45 猪猪🐷 阅读(109) 评论(0) 推荐(0)

67. Add Binary

摘要: this one is two strings added together. Still need to add the Two element from two string from the last digit Use a string builder to add backwards, b 阅读全文

posted @ 2018-07-18 09:44 猪猪🐷 阅读(104) 评论(0) 推荐(0)

66. Plus One

摘要: Plus one : so There are a case when the last one is 9, then 1 plus 9 is 0, continue to check if the previous element is 9 or other numbers , if the pr 阅读全文

posted @ 2018-07-18 09:44 猪猪🐷 阅读(369) 评论(0) 推荐(0)

138. Copy List with Random Pointer

摘要: A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null. Return a deep copy 阅读全文

posted @ 2018-07-18 09:37 猪猪🐷 阅读(101) 评论(0) 推荐(0)

328. Odd Even Linked List

摘要: Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the 阅读全文

posted @ 2018-07-18 09:31 猪猪🐷 阅读(65) 评论(0) 推荐(0)

141. Linked List Cycle

摘要: Given a linked list, determine if it has a cycle in it. Follow up:Can you solve it without using extra space? Given a linked list, determine if it has 阅读全文

posted @ 2018-07-18 09:28 猪猪🐷 阅读(61) 评论(0) 推荐(0)

369. Plus One Linked List

摘要: Given a non-negative integer represented as non-empty a singly linked list of digits, plus one to the integer. You may assume the integer do not conta 阅读全文

posted @ 2018-07-18 09:27 猪猪🐷 阅读(94) 评论(0) 推荐(0)

445. Add Two Numbers II

摘要: You are given two non-empty linked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contai 阅读全文

posted @ 2018-07-18 09:26 猪猪🐷 阅读(114) 评论(0) 推荐(0)

2. Add Two Numbers

摘要: You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contai 阅读全文

posted @ 2018-07-18 09:25 猪猪🐷 阅读(79) 评论(0) 推荐(0)

160. Intersection of Two Linked Lists

摘要: Write a program to find the node at which the intersection of two singly linked lists begins. For example, the following two linked lists: begin to in 阅读全文

posted @ 2018-07-18 09:24 猪猪🐷 阅读(108) 评论(0) 推荐(0)

21. Merge Two Sorted Lists

摘要: Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. Example: 阅读全文

posted @ 2018-07-18 09:21 猪猪🐷 阅读(75) 评论(0) 推荐(0)

86. Partition List

摘要: Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the 阅读全文

posted @ 2018-07-18 09:20 猪猪🐷 阅读(83) 评论(0) 推荐(0)

61. Rotate List

摘要: Given a linked list, rotate the list to the right by k places, where k is non-negative. Example 1: Input: 1->2->3->4->5->NULL, k = 2 Output: 4->5->1-> 阅读全文

posted @ 2018-07-18 09:19 猪猪🐷 阅读(72) 评论(0) 推荐(0)

82. Remove Duplicates from Sorted List II

摘要: Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. Example 1: Example 2: 阅读全文

posted @ 2018-07-18 09:17 猪猪🐷 阅读(74) 评论(0) 推荐(0)

83. Remove Duplicates from Sorted List

摘要: Given a sorted linked list, delete all duplicates such that each element appear only once. Example 1: Example 2: 阅读全文

posted @ 2018-07-18 09:16 猪猪🐷 阅读(53) 评论(0) 推荐(0)

19. Remove Nth Node From End of List

摘要: Given a linked list, remove the n-th node from the end of list and return its head. Example: Note: Given n will always be valid. Follow up: Could you 阅读全文

posted @ 2018-07-18 09:15 猪猪🐷 阅读(74) 评论(0) 推荐(0)

237. Delete Node in a Linked List

摘要: Write a function to delete a node (except the tail) in a singly linked list, given only access to that node. Given linked list -- head = [4,5,1,9], wh 阅读全文

posted @ 2018-07-18 09:14 猪猪🐷 阅读(70) 评论(0) 推荐(0)

203. Remove Linked List Elements

摘要: Remove all elements from a linked list of integers that have value val. Example: 阅读全文

posted @ 2018-07-18 09:13 猪猪🐷 阅读(63) 评论(0) 推荐(0)

206. Reverse Linked List

摘要: Reverse a singly linked list. Example: Follow up: A linked list can be reversed either iteratively or recursively. Could you implement both? 阅读全文

posted @ 2018-07-18 09:10 猪猪🐷 阅读(100) 评论(0) 推荐(0)

274. H-Index

摘要: Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index. According 阅读全文

posted @ 2018-07-18 09:06 猪猪🐷 阅读(100) 评论(0) 推荐(0)

523. Continuous Subarray Sum ( if the array has a continuous subarray of size at least 2 that sums up to the multiple of k or k )

摘要: (找到连续的 subarray 和等于 k (不需要 k 的倍数) https://github.com/tongzhang1994/Facebook-Interview-Coding/blob/master/Subarray%20Sum.java Given a list of non-negat 阅读全文

posted @ 2018-07-18 09:05 猪猪🐷 阅读(154) 评论(0) 推荐(0)

525. Contiguous Array

摘要: Given a binary array, find the maximum length of a contiguous subarray with equal number of 0 and 1. Example 1: Input: [0,1] Output: 2 Explanation: [0 阅读全文

posted @ 2018-07-18 09:04 猪猪🐷 阅读(123) 评论(0) 推荐(0)

209. Minimum Size Subarray Sum

摘要: 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 阅读全文

posted @ 2018-07-18 09:03 猪猪🐷 阅读(101) 评论(0) 推荐(0)

325. Maximum Size Subarray Sum Equals k (maximum length of a subarray that sums to k.)

摘要: Given an array nums and a target value k, find the maximum length of a subarray that sums to k. If there isn't one, return 0 instead. Note:The sum of 阅读全文

posted @ 2018-07-18 09:02 猪猪🐷 阅读(113) 评论(0) 推荐(0)

560. Subarray Sum Equals K ( find the total number of continuous subarrays whose sum equals to k.)

摘要: 练习把start 和end 的index打印出来。。 类似LC560,还要简单,只需要返回true/false就行。follow up: overflow如何解决 Given an array of integers and an integer k, you need to find the to 阅读全文

posted @ 2018-07-18 09:01 猪猪🐷 阅读(114) 评论(0) 推荐(0)

导航