摘要: Invert a binary tree. Example: Input: Output: 非递归的方法 阅读全文
posted @ 2019-02-25 15:10 月半榨菜 阅读(111) 评论(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)
摘要: 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 月半榨菜 阅读(121) 评论(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 月半榨菜 阅读(100) 评论(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 月半榨菜 阅读(93) 评论(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 月半榨菜 阅读(100) 评论(0) 推荐(0)
摘要: Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction 阅读全文
posted @ 2019-02-25 09:47 月半榨菜 阅读(146) 评论(0) 推荐(0)
摘要: Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest le 阅读全文
posted @ 2019-02-25 09:46 月半榨菜 阅读(102) 评论(0) 推荐(0)
摘要: You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you cli 阅读全文
posted @ 2019-02-25 09:45 月半榨菜 阅读(106) 评论(0) 推荐(0)
摘要: Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. Example: Foll 阅读全文
posted @ 2019-02-25 09:43 月半榨菜 阅读(123) 评论(0) 推荐(0)
摘要: 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 @ 2019-02-25 09:41 月半榨菜 阅读(90) 评论(0) 推荐(0)
摘要: Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: No 阅读全文
posted @ 2019-02-25 09:26 月半榨菜 阅读(142) 评论(0) 推荐(0)
摘要: 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 @ 2019-02-25 09:23 月半榨菜 阅读(88) 评论(0) 推荐(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 exa 阅读全文
posted @ 2019-02-25 09:13 月半榨菜 阅读(138) 评论(0) 推荐(0)