随笔分类 -  LeetCode

摘要:题目: Given a non-empty array of integers, return the k most frequent elements. For example,Given [1,1,1,2,2,3] and k = 2, return [1,2]. Note: You may a 阅读全文
posted @ 2016-08-06 11:26 zhangbaochong 阅读(231) 评论(0) 推荐(0)
摘要:题目: Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is the root-to-leaf path 1->2->3  阅读全文
posted @ 2016-06-09 20:21 zhangbaochong 阅读(222) 评论(0) 推荐(0)
摘要:题目: Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root). 阅读全文
posted @ 2016-05-17 20:00 zhangbaochong 阅读(314) 评论(0) 推荐(0)
摘要:题目: Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree is symmetric: But the 阅读全文
posted @ 2016-05-14 17:29 zhangbaochong 阅读(551) 评论(0) 推荐(0)
摘要:题目: Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the answer is "abc", which the 阅读全文
posted @ 2016-05-12 21:32 zhangbaochong 阅读(309) 评论(0) 推荐(0)
摘要:题目: Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. For example,Given  阅读全文
posted @ 2016-05-10 19:45 zhangbaochong 阅读(248) 评论(0) 推荐(0)
摘要:题目: Given a list, rotate the list to the right by k places, where k is non-negative. For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2 阅读全文
posted @ 2016-05-09 20:24 zhangbaochong 阅读(273) 评论(0) 推荐(0)
摘要:题目: Given a list, rotate the list to the right by k places, where k is non-negative. For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2 阅读全文
posted @ 2016-05-07 20:45 zhangbaochong 阅读(245) 评论(0) 推荐(0)
摘要:题目: Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integ 阅读全文
posted @ 2016-05-06 22:14 zhangbaochong 阅读(199) 评论(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 m 阅读全文
posted @ 2016-04-18 20:58 zhangbaochong 阅读(269) 评论(0) 推荐(0)
摘要:题目: Reverse a linked list from position m to n. Do it in-place and in one-pass. For example:Given 1->2->3->4->5->NULL, m = 2 and n = 4, return 1->4->3 阅读全文
posted @ 2016-03-17 15:19 zhangbaochong 阅读(190) 评论(0) 推荐(0)
摘要:题目: 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 Wikip 阅读全文
posted @ 2016-03-13 13:40 zhangbaochong 阅读(341) 评论(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 a 阅读全文
posted @ 2016-03-10 17:45 zhangbaochong 阅读(180) 评论(0) 推荐(0)
摘要:题目: Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. The brackets must close in 阅读全文
posted @ 2016-03-07 13:58 zhangbaochong 阅读(158) 评论(0) 推荐(0)
摘要:题目: You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each 阅读全文
posted @ 2016-03-06 17:29 zhangbaochong 阅读(346) 评论(0) 推荐(0)
摘要:题目: Given a singly linked list, determine if it is a palindrome. 判断一个单链表是不是回文 思路: 1、遍历整个链表,将链表每个节点的值记录在数组中,再判断数组是不是一个回文数组,时间复杂度为O(n),但空间复杂度也为O(n),不满足空 阅读全文
posted @ 2016-03-04 22:09 zhangbaochong 阅读(290) 评论(0) 推荐(0)
摘要:题目: Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums exc 阅读全文
posted @ 2016-03-03 14:27 zhangbaochong 阅读(178) 评论(0) 推荐(0)
摘要:题目: Given a binary tree, return all root-to-leaf paths. For example, given the following binary tree: 1 / \ 2 3 \ 5 All root-to-leaf paths are: ["1->2 阅读全文
posted @ 2016-02-29 22:08 zhangbaochong 阅读(277) 评论(0) 推荐(0)
摘要:题目: Given a pattern and a string str, find if str follows the same pattern. Here follow means a full match, such that there is a bijection between a l 阅读全文
posted @ 2016-02-13 19:06 zhangbaochong 阅读(278) 评论(0) 推荐(0)
摘要:题目: Given a linked list, remove the nth node from the end of list and return its head. For example, Given linked list: 1->2->3->4->5, and n = 2. After 阅读全文
posted @ 2016-02-10 19:02 zhangbaochong 阅读(286) 评论(0) 推荐(0)