摘要: Given a set of distinct integers, nums, return all possible subsets (the power set). Note: The solution set must not contain duplicate subsets. Exampl 阅读全文
posted @ 2020-02-17 23:46 hyx1 阅读(95) 评论(0) 推荐(0) 编辑
摘要: Given an array with n objects colored red, white or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the or 阅读全文
posted @ 2020-02-17 23:34 hyx1 阅读(92) 评论(0) 推荐(0) 编辑
摘要: 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 @ 2020-02-17 23:06 hyx1 阅读(83) 评论(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 @ 2020-02-17 22:58 hyx1 阅读(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 runti 阅读全文
posted @ 2020-02-17 22:49 hyx1 阅读(65) 评论(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 l 阅读全文
posted @ 2020-02-17 22:46 hyx1 阅读(69) 评论(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 cl 阅读全文
posted @ 2020-02-17 22:37 hyx1 阅读(122) 评论(0) 推荐(0) 编辑
摘要: Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path. 阅读全文
posted @ 2020-02-17 22:34 hyx1 阅读(81) 评论(0) 推荐(0) 编辑
摘要: A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any p 阅读全文
posted @ 2020-02-17 22:25 hyx1 阅读(133) 评论(0) 推荐(0) 编辑
摘要: Given a collection of intervals, merge all overlapping intervals. Example 1: Input: [[1,3],[2,6],[8,10],[15,18]] Output: [[1,6],[8,10],[15,18]] Explan 阅读全文
posted @ 2020-02-17 22:22 hyx1 阅读(163) 评论(0) 推荐(0) 编辑
摘要: Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maxim 阅读全文
posted @ 2020-02-17 21:51 hyx1 阅读(96) 评论(0) 推荐(0) 编辑
摘要: 题目描述 输入两个单调递增的链表,输出两个链表合成后的链表,当然我们需要合成后的链表满足单调不减规则。 1 /* 2 public class ListNode { 3 int val; 4 ListNode next = null; 5 6 ListNode(int val) { 7 this.v 阅读全文
posted @ 2020-02-17 19:40 hyx1 阅读(96) 评论(0) 推荐(0) 编辑
摘要: 题目描述 输入一个链表,反转链表后,输出新链表的表头。 1 /* 2 public class ListNode { 3 int val; 4 ListNode next = null; 5 6 ListNode(int val) { 7 this.val = val; 8 } 9 }*/ 10 p 阅读全文
posted @ 2020-02-17 19:34 hyx1 阅读(74) 评论(0) 推荐(0) 编辑
摘要: 题目描述 给一个链表,若其中包含环,请找出该链表的环的入口结点,否则,输出null。 1 /* 2 public class ListNode { 3 int val; 4 ListNode next = null; 5 6 ListNode(int val) { 7 this.val = val; 阅读全文
posted @ 2020-02-17 19:26 hyx1 阅读(113) 评论(0) 推荐(0) 编辑
摘要: 题目描述 输入一个链表,输出该链表中倒数第k个结点。 1 /* 2 public class ListNode { 3 int val; 4 ListNode next = null; 5 6 ListNode(int val) { 7 this.val = val; 8 } 9 }*/ 10 pu 阅读全文
posted @ 2020-02-17 19:05 hyx1 阅读(98) 评论(0) 推荐(0) 编辑
摘要: 题目描述 输入一个整数数组,实现一个函数来调整该数组中数字的顺序,使得所有的奇数位于数组的前半部分,所有的偶数位于数组的后半部分,并保证奇数和奇数,偶数和偶数之间的相对位置不变。 1 public class Solution { 2 public void swap(int [] array, i 阅读全文
posted @ 2020-02-17 18:51 hyx1 阅读(99) 评论(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: Inpu 阅读全文
posted @ 2020-02-17 18:43 hyx1 阅读(83) 评论(0) 推荐(0) 编辑
摘要: Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. 阅读全文
posted @ 2020-02-17 18:19 hyx1 阅读(108) 评论(0) 推荐(0) 编辑
摘要: You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Note: You have to rotate the image in-place, which 阅读全文
posted @ 2020-02-17 16:32 hyx1 阅读(127) 评论(0) 推荐(0) 编辑
摘要: iven an array of strings, group anagrams together. Example: Input: ["eat", "tea", "tan", "ate", "nat", "bat"], Output: [ ["ate","eat","tea"], ["nat"," 阅读全文
posted @ 2020-02-17 15:55 hyx1 阅读(108) 评论(0) 推荐(0) 编辑