程序员的世界, 为程序员服务

2016-06-29
LeetCode-Min Stack

##题目 ####Min Stack Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) – Push element x onto stack. pop() – Removes the element on top of the stack. top() – Get the top element. getMin() – Retrieve the minimum element in the stack.

Read More

2016-06-29
LeetCode-Minimum Path Sum

##题目 ####Minimum Path Sum 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. Note: You can only move either down or right at any point in time.

Read More

2016-06-29
LeetCode-Minimum Depth of Binary Tree

##题目 ####Minimum Depth of Binary Tree Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.

Read More

2016-06-29
LeetCode-Minimum Size Subarray Sum

##题目 ####Minimum Size Subarray Sum Given an array of n positive integers and a positive integer s, find the minimal length of a subarray of which the sum ≥ s. If there isn’t one, return 0 instead. For example, given the array [2,3,1,2,4,3] and s = 7,the subarray [4,3] has the minimal length under t

Read More

2016-06-29
LeetCode-Minimum Window Substring

##题目 ####Minimum Window Substring Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). For example,S = "ADOBECODEBANC"T = "ABC"Minimum window is "BANC". Note:If there is no such window in S tha

Read More

2016-06-29
MongoDB数据库介绍和基本操作

本文主要介绍了mongoDB的基本内容和其一些基本操作。

Read More

2016-06-29
LeetCode-Multiply Strings

##题目 ####Multiply Strings Given two numbers represented as strings, return multiplication of the numbers as a string. Note: The numbers can be arbitrarily large and are non-negative.

Read More

2016-06-29
LeetCode-N-Queens II

##题目 ####N-Queens II Follow up for N-Queens problem. Now, instead outputting board configurations, return the total number of distinct solutions.

Read More

2016-06-29
LeetCode-N-Queens

##题目 ####N-Queens The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return all distinct solutions to the n-queens puzzle. Each solution contains a distinct board configuration of the n-queens’ placement, where

Read More

2016-06-29
LeetCode-Next Permutation

##题目 ####Next Permutation Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possible, it must rearrange it as the lowest possible order (ie, sorted in ascending order). The replacement must be in-place, d

Read More

2016-06-29
LeetCode-Nth Highest Salary

##题目 ####Nth Highest Salary Write a SQL query to get the nth highest salary from the Employee table. +----+--------+ | Id | Salary | +----+--------+ | 1 | 100 | | 2 | 200 | | 3 | 300 | +----+--------+ For example, given the above Employee table, the nth highest salary where n = 2 is 200

Read More

2016-06-29
设置Reducer数目

##一、实验内容本篇介绍如何控制reduce的数目。当结果文件很多时,都会发现一般是以part-r-00000 形式出现多个文件,其实这个reducer的数目有关系,reducer数目多,结果文件数目就多。

Read More

2016-06-29
LeetCode-Number of 1 Bits

##题目 ####Number of 1 Bits Write a function that takes an unsigned integer and returns the number of ’1’ bits it has (also known as the Hamming weight). For example, the 32-bit integer ’11’ has binary representation 00000000000000000000000000001011, so the function should return 3. ####Credits:Speci

Read More

2016-06-29
LeetCode-Number of Islands

##题目 ####Number of Islands Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water.

Read More

2016-06-29
LeetCode-Palindrome Partitioning II

##题目 ####Palindrome Partitioning II Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning of s. For example, given s = "aab",Return 1 since the palindrome partitioning ["aa","b&

Read More

2016-06-29
LeetCode-Palindrome Partitioning

##题目 ####Palindrome Partitioning Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. For example, given s = “aab”,Return [ ["aa","b"], ["a","a","b"]

Read More

2016-06-29
LeetCode-Partition List

##题目 ####Partition List Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the original relative order of the nodes in each of the two partitions. For example,Given 1->4->3->2->5->2 and x

Read More

2016-06-29
LeetCode-Pascal's Triangle II

##题目 ####Pascal’s Triangle II Given an index k, return the kth row of the Pascal’s triangle. For example, given k = 3,Return [1,3,3,1]. ####Note:Could you optimize your algorithm to use only O(k) extra space?

Read More

2016-06-29
LeetCode-Path Sum

##题目 ####Path Sum Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. For example:Given the below binary tree and sum = 22, 5 / \ 4 8 / / \ 11 13 4 / \ \ 7 2 1 r

Read More

2016-06-29
LeetCode-Pascal's Triangle

##题目 ####Pascal’s Triangle Given numRows, generate the first numRows of Pascal’s triangle. For example, given numRows = 5,Return [ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] ]

Read More