随笔分类 -  LeetCode

摘要:Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of LCA on Wikipedia 阅读全文
posted @ 2019-03-25 10:56 月半榨菜 阅读(140) 评论(0) 推荐(0)
摘要:Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left subtree of a node contains only 阅读全文
posted @ 2019-03-25 10:31 月半榨菜 阅读(139) 评论(0) 推荐(0)
摘要:Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c + d = target? Find all unique q 阅读全文
posted @ 2019-03-22 18:59 月半榨菜 阅读(124) 评论(0) 推荐(0)
摘要:Given an array nums of n integers, are there elements a, b, c in nums such that a + b+ c = 0? Find all unique triplets in the array which gives the su 阅读全文
posted @ 2019-03-22 17:12 月半榨菜 阅读(147) 评论(0) 推荐(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. 针对每个字符串, 阅读全文
posted @ 2019-03-22 10:26 月半榨菜 阅读(140) 评论(0) 推荐(0)
摘要:Given two strings s and t , write a function to determine if t is an anagram of s. Example 1: Example 2: Note:You may assume the string contains only 阅读全文
posted @ 2019-03-21 21:09 月半榨菜 阅读(146) 评论(0) 推荐(0)
摘要:Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k num 阅读全文
posted @ 2019-03-20 21:18 月半榨菜 阅读(135) 评论(0) 推荐(0)
摘要:Design a class to find the kth largest element in a stream. Note that it is the kth largest element in the sorted order, not the kth distinct element. 阅读全文
posted @ 2019-03-20 17:24 月半榨菜 阅读(122) 评论(0) 推荐(0)
摘要:Implement the following operations of a stack using queues. push(x) -- Push element x onto stack. pop() -- Removes the element on top of the stack. to 阅读全文
posted @ 2019-03-20 15:26 月半榨菜 阅读(111) 评论(0) 推荐(0)
摘要:Implement the following operations of a queue using stacks. push(x) -- Push element x to the back of queue. pop() -- Removes the element from in front 阅读全文
posted @ 2019-03-20 15:20 月半榨菜 阅读(134) 评论(0) 推荐(0)
摘要:Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. k is a positive integer and is less than or equal to 阅读全文
posted @ 2019-03-20 10:45 月半榨菜 阅读(99) 评论(0) 推荐(0)
摘要:Given a linked list, return the node where the cycle begins. If there is no cycle, return null. To represent a cycle in the given linked list, we use 阅读全文
posted @ 2019-03-19 20:37 月半榨菜 阅读(152) 评论(0) 推荐(0)
摘要:Given a linked list, determine if it has a cycle in it. To represent a cycle in the given linked list, we use an integer pos which represents the posi 阅读全文
posted @ 2019-03-19 19:45 月半榨菜 阅读(150) 评论(0) 推荐(0)
摘要:Given a linked list, swap every two adjacent nodes and return its head. You may not modify the values in the list's nodes, only nodes itself may be ch 阅读全文
posted @ 2019-03-19 16:03 月半榨菜 阅读(120) 评论(0) 推荐(0)
摘要:Given a non-empty array of integers, return the k most frequent elements. Example 1: Example 2: Input: nums = [1], k = 1 Output: [1] Example 2: Note: 阅读全文
posted @ 2019-02-26 11:38 月半榨菜 阅读(106) 评论(0) 推荐(0)
摘要:Given a binary tree, return the inorder traversal of its nodes' values. Example: Follow up: Recursive solution is trivial, could you do it iteratively 阅读全文
posted @ 2019-02-26 10:39 月半榨菜 阅读(113) 评论(0) 推荐(0)
摘要:Invert a binary tree. Example: Input: Output: 非递归的方法 阅读全文
posted @ 2019-02-25 15:10 月半榨菜 阅读(109) 评论(0) 推荐(0)
摘要:Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements. Example: Note: 阅读全文
posted @ 2019-02-25 15:08 月半榨菜 阅读(114) 评论(0) 推荐(0)
摘要: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 r 阅读全文
posted @ 2019-02-25 15:05 月半榨菜 阅读(159) 评论(0) 推荐(0)
摘要:You're given strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in S is a type of ston 阅读全文
posted @ 2019-02-25 10:53 月半榨菜 阅读(126) 评论(0) 推荐(0)