LeetCode
经典面试算法分析,一起探讨面试算法
Wang-Junchao
这个作者很懒,什么都没留下…
展开
-
【LeetCode-面试算法经典-Java实现】【226-Invert Binary Tree(反转二叉树)】
【226-Invert Binary Tree(反转二叉树)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】代码下载【https://github.com/Wang-Jun-Chao】原题 Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9 to 4 / \ 7原创 2015-08-30 06:24:34 · 5956 阅读 · 12 评论 -
【LeetCode-面试算法经典-Java实现】【225-Implement Stack using Queues(用队列实现栈操作)】
【225-Implement Stack using Queues(用队列实现栈操作)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】代码下载【https://github.com/Wang-Jun-Chao】原题 Implement the following operations of a stack using queues. push(x) – Push ele原创 2015-08-29 06:42:41 · 4244 阅读 · 0 评论 -
【LeetCode-面试算法经典-Java实现】【223-Rectangle Area(矩形区域)】
【223-Rectangle Area(矩形区域)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】代码下载【https://github.com/Wang-Jun-Chao】原题 Find the total area covered by two rectilinear rectangles in a 2D plane. Each rectangle is defined原创 2015-08-29 06:39:48 · 4063 阅读 · 1 评论 -
【LeetCode-面试算法经典-Java实现】【219-Contains Duplicate II(包含重复元素II)】
【219-Contains Duplicate II(包含重复元素II)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】代码下载【https://github.com/Wang-Jun-Chao】原题 Given an array of integers and an integer k, find out whether there are two distinct ind原创 2015-08-29 06:36:21 · 5025 阅读 · 1 评论 -
【LeetCode-面试算法经典-Java实现】【217-Contains Duplicate(包含重复元素)】
【217-Contains Duplicate(包含重复元素)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】代码下载【https://github.com/Wang-Jun-Chao】原题 Given an array of integers, find if the array contains any duplicates. Your function should r原创 2015-08-28 07:00:49 · 4287 阅读 · 0 评论 -
【LeetCode-面试算法经典-Java实现】【216-Combination Sum III (组合数的和)】
【216-Combination Sum III (组合数的和)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】代码下载【https://github.com/Wang-Jun-Chao】原题 Find all possible combinations of k numbers that add up to a number n, given that only numbe原创 2015-08-28 06:58:38 · 4966 阅读 · 0 评论 -
【LeetCode-面试算法经典-Java实现】【215-Kth Largest Element in an Array(数组中第K大的数)】
【215-Kth Largest Element in an Array(数组中第K大的数)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】代码下载【https://github.com/Wang-Jun-Chao】原题 Find the kth largest element in an unsorted array. Note that it is the kth lar原创 2015-08-28 06:57:17 · 6310 阅读 · 0 评论 -
【LeetCode-面试算法经典-Java实现】【206-Reverse Linked List(反转一个单链表)】
【206-Reverse Linked List(反转一个单链表)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】代码下载【https://github.com/Wang-Jun-Chao】原题 Reverse a singly linked list. 题目大意 反转单链表。 解题思路 使用头插法。 代码实现结点类public class ListNode {原创 2015-08-27 06:35:40 · 5347 阅读 · 0 评论 -
【LeetCode-面试算法经典-Java实现】【205-Isomorphic Strings(同构字符串)】
【205-Isomorphic Strings(同构字符串)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】代码下载【https://github.com/Wang-Jun-Chao】原题 Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if原创 2015-08-27 06:33:32 · 6204 阅读 · 1 评论 -
【LeetCode-面试算法经典-Java实现】【204-Count Primes(统计质数)】
【204-Count Primes(统计质数)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】代码下载【https://github.com/Wang-Jun-Chao】原题 Description: Count the number of prime numbers less than a non-negative number, n. 题目大意 统计小于非负整数原创 2015-08-27 06:30:01 · 4871 阅读 · 0 评论 -
【LeetCode-面试算法经典-Java实现】【202-Happy Number(开心数字)】
【202-Happy Number(开心数字)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】代码下载【https://github.com/Wang-Jun-Chao】原题 Write an algorithm to determine if a number is “happy”. A happy number is a number defined by the原创 2015-08-26 07:20:12 · 7823 阅读 · 1 评论 -
【LeetCode-面试算法经典-Java实现】【201-Bitwise AND of Numbers Range(范围数位与结果)】
【201-Bitwise AND of Numbers Range(范围数位与结果)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】代码下载【https://github.com/Wang-Jun-Chao】原题 Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of al原创 2015-08-26 07:18:11 · 4296 阅读 · 1 评论 -
【LeetCode-面试算法经典-Java实现】【190-Reverse Bits(反转二制)】
【190-Reverse Bits(反转二制)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】代码下载【https://github.com/Wang-Jun-Chao】原题 Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented i原创 2015-08-24 07:15:15 · 5209 阅读 · 0 评论 -
【LeetCode-面试算法经典-Java实现】【189-Rotate Array(旋转数组)】
【189-Rotate Array(旋转数组)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Rotate an array of n elements to the right by k steps. For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7原创 2015-08-24 07:13:21 · 5423 阅读 · 0 评论 -
【LeetCode-面试算法经典-Java实现】【152-Maximum Product Subarray(子数组的最大乘积)】
【152-Maximum Product Subarray(子数组的最大乘积)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】代码下载【https://github.com/Wang-Jun-Chao】原题 Find the contiguous subarray within an array (containing at least one number) which h原创 2015-08-24 07:07:12 · 3959 阅读 · 0 评论 -
【LeetCode-面试算法经典-Java实现】【172-Factorial Trailing Zeroes(阶乘尾后0的数目)】
【172-Factorial Trailing Zeroes(阶乘尾后0的数目)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】代码下载【https://github.com/Wang-Jun-Chao】原题 Given an integer n, return the number of trailing zeroes in n!. Note: Your soluti原创 2015-08-23 06:43:47 · 3565 阅读 · 0 评论 -
【LeetCode-面试算法经典-Java实现】【171-Excel Sheet Column Number(Excel表行号)】
【171-Excel Sheet Column Number(Excel表行号)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】代码下载【https://github.com/Wang-Jun-Chao】原题 Given a column title as appear in an Excel sheet, return its corresponding column nu原创 2015-08-23 06:41:06 · 4165 阅读 · 1 评论 -
【LeetCode-面试算法经典-Java实现】【169-Majority Element(主元素)】
【169-Majority Element(主元素)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】代码下载【https://github.com/Wang-Jun-Chao】原题 Given an array of size n, find the majority element. The majority element is the element that appe原创 2015-08-23 06:38:30 · 6196 阅读 · 0 评论 -
【LeetCode-面试算法经典-Java实现】【168-Excel Sheet Column Title(Excell列标题)】
【168-Excel Sheet Column Title(Excell列标题)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given a positive integer, return its corresponding column title as appear in an Excel sheet. For example: 1 -> A原创 2015-08-22 06:51:46 · 4214 阅读 · 4 评论 -
【LeetCode-面试算法经典-Java实现】【165-Compare Version Numbers(比较版本号)】
【165-Compare Version Numbers(比较版本号)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Compare two version numbers version1 and version2. If version1 > version2 return 1, if version1 < version2 return -1, otherw原创 2015-08-22 06:49:39 · 4128 阅读 · 0 评论 -
【LeetCode-面试算法经典-Java实现】【160-Intersection of Two Linked Lists(单链表的交集)】
【160-Intersection of Two Linked Lists(单链表的交集)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Write a program to find the node at which the intersection of two singly linked lists begins. For example, the fol原创 2015-08-22 06:45:36 · 5192 阅读 · 1 评论 -
【LeetCode-面试算法经典-Java实现】【150-Evaluate Reverse Polish Notation(计算逆波兰式)】
【151-Evaluate Reverse Polish Notation(计算逆波兰式)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Each ope原创 2015-08-20 06:37:59 · 3777 阅读 · 0 评论 -
【LeetCode-面试算法经典-Java实现】【151-Reverse Words in a String(反转字符串中的单词)】
【152-Reverse Words in a String(反转字符串中的单词)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given an input string, reverse the string word by word. For example, Given s = "the sky is blue", return "blue i原创 2015-08-20 06:35:37 · 3837 阅读 · 1 评论 -
【LeetCode-面试算法经典-Java实现】【147-Insertion Sort List(链表插入排序)】
【147-Insertion Sort List(链表插入排序)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Sort a linked list using insertion sort. 题目大意 对一个单链表表进行插入排序 解题思路 使用一个指针p指向未排好序的链表的第一个结点,在排序好的部分中找到找第一个大于等于q的前驱结点,将p对应的结点插入到正确位原创 2015-08-20 06:33:12 · 3945 阅读 · 0 评论 -
【LeetCode-面试算法经典-Java实现】【145-Binary Tree Postorder Traversal(二叉树非递归后序遍历)】
【144-Binary Tree Postorder Traversal(二叉树非递归后序遍历)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given a binary tree, return the postorder traversal of its nodes’ values. For example: Given binary tree {1,原创 2015-08-19 06:56:00 · 3377 阅读 · 0 评论 -
【LeetCode-面试算法经典-Java实现】【144-Binary Tree Preorder Traversal(二叉树非递归前序遍历)】
【144-Binary Tree Preorder Traversal(二叉树非递归前序遍历)(未完成)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given a binary tree, return the preorder traversal of its nodes’ values. For example: Given binary tree原创 2015-08-19 06:53:17 · 2880 阅读 · 0 评论 -
【LeetCode-面试算法经典-Java实现】【143-Copy List with Random Pointer(有随机指针的链表复制)】
【143-Copy List with Random Pointer(有随机指针的链表复制)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 A linked list is given such that each node contains an additional random pointer which could point to any node in th原创 2015-08-19 06:40:20 · 1589 阅读 · 0 评论 -
【LeetCode-面试算法经典-Java实现】【142-Linked List Cycle II(单链表中有环II)】
【142-Linked List Cycle II(单链表中有环II)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Follow up: Can you solve原创 2015-08-19 06:38:29 · 4096 阅读 · 0 评论 -
【LeetCode-面试算法经典-Java实现】【141-Linked List Cycle(单链表中有环)】
【141-Linked List Cycle(单链表中有环)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using extra space? 题目大意 给定一个单链表,原创 2015-08-19 06:36:47 · 3496 阅读 · 0 评论 -
【LeetCode-面试算法经典-Java实现】【139-Word Break(单词拆分)】
【139-Word Break(单词拆分)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary wo原创 2015-08-19 06:34:31 · 6266 阅读 · 1 评论 -
【LeetCode-面试算法经典-Java实现】【138-Copy List with Random Pointer(拷贝有随机指针的单链表)】
【138-Copy List with Random Pointer(拷贝有随机指针的单链表)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 A linked list is given such that each node contains an additional random pointer which could point to any node in t原创 2015-08-18 06:26:06 · 3286 阅读 · 1 评论 -
【LeetCode-面试算法经典-Java实现】【137-Single Number II(只字出一次的数字II)】
【137-Single Number II(只出现一次的数字II)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given an array of integers, every element appears three times except for one. Find that single one. Note: Your algorithm sh原创 2015-08-18 06:24:21 · 6121 阅读 · 0 评论 -
【LeetCode-面试算法经典-Java实现】【136-Single Number(只出现一次的数字)】
【136-Single Number(只出现一次的数字)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a原创 2015-08-18 06:18:14 · 3441 阅读 · 0 评论 -
【LeetCode-面试算法经典-Java实现】【134-Gas Station(加油站问题)】
【134-Gas Station(加油站问题】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. You have a car with an unlimited gas tan原创 2015-08-15 06:18:51 · 5897 阅读 · 0 评论 -
【LeetCode-面试算法经典-Java实现】【130-Surrounded Regions(环绕区域)】
【130-Surrounded Regions(环绕区域)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'. A region is captured by flipping all 'O's into 'X'原创 2015-08-15 06:14:08 · 3508 阅读 · 0 评论 -
【LeetCode-面试算法经典-Java实现】【129-Sum Root to Leaf Numbers(所有根到叶子结点组组成的数字相加)】
【129-Sum Root to Leaf Numbers(所有根到叶子结点组组成的数字相加)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example原创 2015-08-15 06:11:18 · 3017 阅读 · 0 评论 -
【LeetCode-面试算法经典-Java实现】【125-Valid Palindrome(回文字验证)】
【125-Valid Palindrome(回文字验证)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example, "A ma原创 2015-08-14 06:18:42 · 4055 阅读 · 0 评论 -
【LeetCode-面试算法经典-Java实现】【121-Best Time to Buy and Sell Stock(最佳买卖股票的时间)】
【121-Best Time to Buy and Sell Stock(最佳买卖股票的时间)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitt原创 2015-08-14 06:16:32 · 10665 阅读 · 0 评论 -
【LeetCode-面试算法经典-Java实现】【120-Triangle(三角形)】
【120-Triangle(三角形)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. For example, giv原创 2015-08-14 06:13:18 · 4200 阅读 · 0 评论 -
【LeetCode-面试算法经典-Java实现】【119-Pascal's Triangle II(帕斯卡三角形(杨辉三角)II)】
【119-Pascal’s Triangle II(帕斯卡三角形II)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given an index k, return the kth row of the Pascal’s triangle. For example, given k = 3, Return [1,3,3,1]. Note: Co原创 2015-08-13 06:21:37 · 3700 阅读 · 0 评论