摘要: 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 月半榨菜 阅读(102) 评论(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 月半榨菜 阅读(109) 评论(0) 推荐(0) 编辑
摘要: Invert a binary tree. Example: Input: Output: 非递归的方法 阅读全文
posted @ 2019-02-25 15:10 月半榨菜 阅读(103) 评论(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 月半榨菜 阅读(111) 评论(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 月半榨菜 阅读(153) 评论(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 月半榨菜 阅读(121) 评论(0) 推荐(0) 编辑
摘要: Reverse a singly linked list. Example: Follow up:A linked list can be reversed either iteratively or recursively. Could you implement both? 递归 进阶题 两两交 阅读全文
posted @ 2019-02-25 09:54 月半榨菜 阅读(116) 评论(0) 推荐(0) 编辑
摘要: Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the 阅读全文
posted @ 2019-02-25 09:52 月半榨菜 阅读(94) 评论(0) 推荐(0) 编辑
摘要: Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) -- Push element x onto stack. pop() -- Remov 阅读全文
posted @ 2019-02-25 09:50 月半榨菜 阅读(88) 评论(0) 推荐(0) 编辑
摘要: Given a non-empty array of integers, every element appears twice except for one. Find that single one. Note:Your algorithm should have a linear runtim 阅读全文
posted @ 2019-02-25 09:48 月半榨菜 阅读(95) 评论(0) 推荐(0) 编辑