11 2018 档案
摘要:https://leetcode.com/problems/search-a-2d-matrix-ii/ Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the fo
阅读全文
摘要:https://leetcode.com/problems/minimum-size-subarray-sum/ Given an array of n positive integers and a positive integer s, find the minimal length of a
阅读全文
摘要:https://leetcode.com/problems/isomorphic-strings/ Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the chara
阅读全文
摘要:https://leetcode.com/problems/bitwise-and-of-numbers-range/ Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all number
阅读全文
摘要:https://leetcode.com/problems/implement-stack-using-queues/ Implement the following operations of a stack using queues. push(x) -- Push element x onto
阅读全文
摘要:https://leetcode.com/problems/implement-queue-using-stacks/ Implement the following operations of a queue using stacks. push(x) -- Push element x to t
阅读全文
摘要:https://leetcode.com/problems/contains-duplicate-ii/ Given an array of integers and an integer k, find out whether there are two distinct indices i an
阅读全文
摘要:https://leetcode.com/problems/remove-linked-list-elements/ Remove all elements from a linked list of integers that have value val. Example: 递归代码: /**
阅读全文
摘要:https://leetcode.com/problems/linked-list-cycle/ Given a linked list, determine if it has a cycle in it. Follow up:Can you solve it without using extr
阅读全文
摘要:https://leetcode.com/problems/longest-consecutive-sequence/ Given an unsorted array of integers, find the length of the longest consecutive elements s
阅读全文
摘要:1.冒泡排序 这个写法是先把小的数字排出来然后再排出来大的数字 代码: #include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; int n; int num[maxn]; void BubbleSort(int
阅读全文
摘要:https://leetcode.com/problems/evaluate-reverse-polish-notation/ Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid opera
阅读全文
摘要:https://leetcode.com/problems/single-number-ii/ Given a non-empty array of integers, every element appears three times except for one, which appears e
阅读全文
摘要:https://leetcode.com/problems/largest-number/ Given a list of non negative integers, arrange them such that they form the largest number. Example 1: E
阅读全文
摘要:https://leetcode.com/problems/factorial-trailing-zeroes/ Given an integer n, return the number of trailing zeroes in n!. Example 1: Example 2: Note: Y
阅读全文
摘要:https://leetcode.com/problems/excel-sheet-column-number/ Given a column title as appear in an Excel sheet, return its corresponding column number. For
阅读全文
摘要:https://leetcode.com/problems/excel-sheet-column-title/ Given a positive integer, return its corresponding column title as appear in an Excel sheet. F
阅读全文
摘要:https://leetcode.com/problems/maximum-gap/ Given an unsorted array, find the maximum difference between the successive elements in its sorted form. Re
阅读全文
摘要:https://leetcode.com/problems/min-stack/ Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) --
阅读全文
摘要:https://leetcode.com/problems/compare-version-numbers/ Compare two version numbers version1 and version2.If version1 > version2 return 1; if version1
阅读全文
摘要:https://leetcode.com/problems/find-peak-element/ A peak element is an element that is greater than its neighbors. Given an input array nums, where num
阅读全文
摘要:https://leetcode.com/problems/find-minimum-in-rotated-sorted-array-ii/ Suppose an array sorted in ascending order is rotated at some pivot unknown to
阅读全文
摘要:https://leetcode.com/problems/find-minimum-in-rotated-sorted-array/ Suppose an array sorted in ascending order is rotated at some pivot unknown to you
阅读全文
摘要:https://leetcode.com/problems/reverse-words-in-a-string/ Given an input string, reverse the string word by word. Example: Note: A word is defined as a
阅读全文
摘要:https://leetcode.com/problems/number-of-islands/ Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrou
阅读全文
摘要:https://leetcode.com/problems/house-robber/ You are a professional robber planning to rob houses along a street. Each house has a certain amount of mo
阅读全文
摘要:https://leetcode.com/problems/reverse-bits/ Reverse bits of a given 32 bits unsigned integer. Example: 代码: Easy 杀手
阅读全文
摘要:Given an array, rotate the array to the right by k steps, where k is non-negative. Example 1: Example 2: 代码:
阅读全文
摘要:https://leetcode.com/problems/number-of-1-bits/ Write a function that takes an unsigned integer and returns the number of '1' bits it has (also known
阅读全文
摘要:https://leetcode.com/problems/triangle/ Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on
阅读全文
摘要:https://leetcode.com/problems/valid-palindrome/ Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring
阅读全文
摘要:https://leetcode.com/problems/remove-duplicates-from-sorted-list/ Given a sorted linked list, delete all duplicates such that each element appear only
阅读全文
摘要:https://pintia.cn/problem-sets/994805260223102976/problems/994805264706813952 给定一段一段的绳子,你需要把它们串成一条绳。每次串连的时候,是把两段绳子对折,再如下图所示套接在一起。这样得到的绳子又被当成是另一段绳子,可以再
阅读全文
摘要:https://pintia.cn/problem-sets/994805260223102976/problems/994805262953594880 给定一个单链表,请编写程序将链表元素进行分类排列,使得所有负值元素都排在非负值元素的前面,而 [0, K] 区间内的元素都排在大于 K 的元素前
阅读全文
摘要:https://pintia.cn/problem-sets/994805260223102976/problems/994805296180871168 给定一个常数 K 以及一个单链表 L,请编写程序将 L 中每 K 个结点反转。例如:给定 L 为 1→2→3→4→5→6,K 为 3,则输出应该
阅读全文
摘要:https://ac.nowcoder.com/acm/contest/96/E?&headNav=www&headNav=acm 题目描述 AA的欧尼酱qwb是个考古学家,有一天qwb发现了只白白圆圆小小的木乃伊,它是个爱哭鬼却很努力。qwb想把这么可爱的小木乃伊送给 AA,于是便找上了快递姐姐,
阅读全文
摘要:A https://ac.nowcoder.com/acm/contest/283/A #include<stdio.h> int main() { for(int i=0;i<90;i++) printf("Ninety for GXU, First for gxuacm\n"); return
阅读全文
摘要:https://leetcode.com/problems/merge-intervals/ Given a collection of intervals, merge all overlapping intervals. Example 1: Example 2: 代码: 那个 $sort$ 排
阅读全文
摘要:https://leetcode.com/problems/combinations/ Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. Example: 代码: 写一会
阅读全文
摘要:https://leetcode.com/problems/subsets-ii/ Given a collection of integers that might contain duplicates, nums, return all possible subsets (the power s
阅读全文
摘要:https://leetcode.com/problems/plus-one/ Given a non-empty array of digits representing a non-negative integer, plus one to the integer. The digits are
阅读全文
摘要:https://leetcode.com/problems/permutation-sequence/ The set [1,2,3,...,n] contains a total of n! unique permutations. By listing and labeling all of t
阅读全文
摘要:https://leetcode.com/problems/minimum-path-sum/ Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which m
阅读全文
摘要:https://leetcode.com/problems/search-a-2d-matrix/ Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the follo
阅读全文
摘要:https://leetcode.com/problems/jump-game/ Given an array of non-negative integers, you are initially positioned at the first index of the array. Each e
阅读全文
摘要:https://leetcode.com/problems/n-queens-ii/ The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack
阅读全文
摘要:https://leetcode.com/problems/next-permutation/ Implement next permutation, which rearranges numbers into the lexicographically next greater permutati
阅读全文
摘要:https://leetcode.com/problems/multiply-strings/ Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and n
阅读全文
摘要:https://leetcode.com/problems/permutations-ii/ Given a collection of numbers that might contain duplicates, return all possible unique permutations. E
阅读全文
摘要:https://leetcode.com/problems/permutations/ Given a collection of distinct integers, return all possible permutations. Example: 代码: 全排列 $dfs$ 写就好的啦 第一
阅读全文
摘要:https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/ Given an array of integers nums sorted in ascending order, find
阅读全文
摘要:https://leetcode.com/problems/4sum/ Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b
阅读全文
摘要:https://leetcode.com/problems/3sum-closest/ Given an array nums of n integers and an integer target, find three integers in nums such that the sum is
阅读全文
摘要:https://leetcode.com/problems/3sum/ Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique tri
阅读全文
摘要:https://leetcode.com/problems/trapping-rain-water/ Given n non-negative integers representing an elevation map where the width of each bar is 1, compu
阅读全文
摘要:https://leetcode.com/problems/unique-paths-ii/ A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The ro
阅读全文
摘要:https://leetcode.com/problems/unique-paths/ A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot
阅读全文
摘要:https://leetcode.com/problems/valid-sudoku/ Determine if a 9x9 Sudoku board is valid. Only the filled cells need to be validated according to the foll
阅读全文
摘要:https://leetcode.com/problems/search-in-rotated-sorted-array/ Suppose an array sorted in ascending order is rotated at some pivot unknown to you befor
阅读全文
摘要:https://leetcode.com/problems/set-matrix-zeroes/ Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in-place. Example
阅读全文
摘要:https://leetcode.com/problems/subsets/ Given a set of distinct integers, nums, return all possible subsets (the power set). Note: The solution set mus
阅读全文
摘要:https://leetcode.com/problems/gray-code/ The gray code is a binary numeral system where two successive values differ in only one bit. Given a non-nega
阅读全文
摘要:https://leetcode.com/problems/maximum-subarray/ Given an integer array nums, find the contiguous subarray (containing at least one number) which has t
阅读全文
摘要:https://leetcode.com/problems/sort-colors/ Given an array with n objects colored red, white or blue, sort them in-place so that objects of the same co
阅读全文
摘要:https://leetcode.com/problems/median-of-two-sorted-arrays/ There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median o
阅读全文
摘要:https://leetcode.com/problems/power-of-four/ Given an integer (signed 32 bits), write a function to check whether it is a power of 4. Example 1: Examp
阅读全文
摘要:https://leetcode.com/problems/reverse-string/ Write a function that takes a string as input and returns the string reversed. Example 1: Input: "hello"
阅读全文
摘要:https://leetcode.com/problems/nim-game/ You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one
阅读全文
摘要:#include using namespace std; /* Problem description: There is an array A, the length of array A is N. You need to perform Q queries. Each query, you get an integer X, and you need to find the ...
阅读全文
摘要:https://leetcode.com/problems/add-binary/ iven two binary strings, return their sum (also a binary string). The input strings are both non-empty and c
阅读全文
摘要:http://codeforces.com/contest/1077/problem/C Let's call an array good if there is an element in the array that equals to the sum of all other elements
阅读全文
摘要:http://codeforces.com/contest/1077/problem/B There is a house with nn flats situated on the main street of Berlatov. Vova is watching this house every
阅读全文
摘要:http://codeforces.com/contest/1077/problem/A A frog is currently at the point 00 on a coordinate axis OxOx. It jumps by the following algorithm: the f
阅读全文
摘要:http://codeforces.com/contest/1075/problem/B Palo Alto is an unusual city because it is an endless coordinate line. It is also known for the office of
阅读全文
摘要:https://leetcode.com/problems/add-two-numbers/ You are given two non-empty linked lists representing two non-negative integers. The digits are stored
阅读全文
摘要:https://leetcode.com/problems/divide-two-integers/ Given two integers dividend and divisor, divide two integers without using multiplication, division
阅读全文
摘要:https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/ Say you have an array for which the ith element is the price of a given stock on day
阅读全文
摘要:https://leetcode.com/problems/best-time-to-buy-and-sell-stock/ Say you have an array for which the ith element is the price of a given stock on day i.
阅读全文
摘要:https://leetcode.com/problems/rotate-image/ You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Note:
阅读全文
摘要:https://leetcode.com/problems/longest-palindromic-substring/ Given a string s, find the longest palindromic substring in s. You may assume that the ma
阅读全文
摘要:https://leetcode.com/problems/sqrtx/ Implement int sqrt(int x). Compute and return the square root of x, where x is guaranteed to be a non-negative in
阅读全文
摘要:https://leetcode.com/problems/climbing-stairs/ You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 o
阅读全文
摘要:https://leetcode.com/problems/powx-n/ Implement pow(x, n), which calculates x raised to the power n (xn). Example 1: Example 2: Example 3: Note: -100.
阅读全文
摘要:https://leetcode.com/problems/guess-number-higher-or-lower/ We are playing the Guess Game. The game is as follows: I pick a number from 1 to n. You ha
阅读全文
摘要:https://leetcode.com/problems/power-of-two/ Given an integer, write a function to determine if it is a power of two. Example 1: Example 2: Example 3:
阅读全文
摘要:https://leetcode.com/problems/valid-anagram/ Given two strings s and t , write a function to determine if t is an anagram of s. Example 1: Example 2:
阅读全文
摘要:https://leetcode.com/problems/contains-duplicate/ Given an array of integers, find if the array contains any duplicates. Your function should return t
阅读全文
摘要:https://leetcode.com/problems/count-primes/ Count the number of prime numbers less than a non-negative number, n. Example: 代码:
阅读全文
摘要:https://leetcode.com/problems/happy-number/ Write an algorithm to determine if a number is "happy". A happy number is a number defined by the followin
阅读全文
摘要:https://leetcode.com/problems/string-to-integer-atoi/ Implement atoi which converts a string to an integer. The function first discards as many whites
阅读全文
摘要:https://leetcode.com/problems/container-with-most-water/ Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (
阅读全文
摘要:https://leetcode.com/problems/implement-strstr/ Implement strStr(). Return the index of the first occurrence of needle in haystack, or -1 if needle is
阅读全文
摘要:http://codeforces.com/contest/1066/problem/B Vova's house is an array consisting of nn elements (yeah, this is the first problem, I think, where someo
阅读全文
摘要:http://codeforces.com/contest/1066/problem/F Maksim walks on a Cartesian plane. Initially, he stands at the point (0,0)(0,0) and in one move he can go
阅读全文
摘要:https://leetcode.com/problems/pascals-triangle-ii/description/ Given a non-negative index k where k ≤ 33, return the kth index row of the Pascal's tri
阅读全文
摘要:http://codeforces.com/contest/1006/problem/A Mishka got an integer array aa of length nn as a birthday present (what a surprise!). Mishka doesn't like
阅读全文
摘要:https://pintia.cn/problem-sets/994805046380707840/problems/994805110318678016 题的目标很简单,就是求两个正整数A和B的和,其中A和B都在区间[1,1000]。稍微有点麻烦的是,输入并不保证是两个正整数。 输入格式: 输入在
阅读全文
摘要:https://pintia.cn/problem-sets/994805342720868352/problems/994805433955368960 Zhejiang University has 40,000 students and provides 2,500 courses. Now
阅读全文
摘要:http://codeforces.com/contest/1075/problem/A On a chessboard with a width of nn and a height of nn, rows are numbered from bottom to top from 11 to nn
阅读全文
摘要:https://leetcode.com/problems/longest-substring-without-repeating-characters/description/ Given a string, find the length of the longest substring wit
阅读全文
摘要:https://leetcode.com/problems/merge-sorted-array/description/ Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted ar
阅读全文
摘要:https://leetcode.com/problems/merge-two-sorted-lists/description/ Merge two sorted linked lists and return it as a new list. The new list should be ma
阅读全文
摘要:https://leetcode.com/problems/pascals-triangle/description/ Given a non-negative integer numRows, generate the first numRows of Pascal's triangle. In
阅读全文
摘要:https://leetcode.com/problems/single-number/description/ Given a non-empty array of integers, every element appears twice except for one. Find that si
阅读全文
摘要:https://leetcode.com/problems/remove-duplicates-from-sorted-array/description/ Given a sorted array nums, remove the duplicates in-place such that eac
阅读全文
摘要:https://leetcode.com/problems/two-sum-ii-input-array-is-sorted/description/ Given an array of integers that is already sorted in ascending order, find
阅读全文
摘要:https://leetcode.com/problems/length-of-last-word/description/ Given a string s consists of upper/lower-case alphabets and empty space characters ' ',
阅读全文
摘要:https://leetcode.com/problems/search-insert-position/description/ Given a sorted array and a target value, return the index if the target is found. If
阅读全文
摘要:http://poj.org/problem?id=2492 Background Professor Hopper is researching the sexual behavior of a rare species of bugs. He assumes that they feature
阅读全文
摘要:https://leetcode.com/problems/remove-element/description/ Given an array nums and a value val, remove all instances of that value in-place and return
阅读全文
摘要:https://leetcode.com/problems/valid-parentheses/description/ Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine
阅读全文
摘要:https://leetcode.com/problems/longest-common-prefix/description/ Write a function to find the longest common prefix string amongst an array of strings
阅读全文
摘要:https://leetcode.com/problems/roman-to-integer/description/ Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. For exa
阅读全文
摘要:https://leetcode.com/problems/palindrome-number/description/ Determine whether an integer is a palindrome. An integer is a palindrome when it reads th
阅读全文
摘要:https://leetcode.com/problems/reverse-integer/description/ Given a 32-bit signed integer, reverse digits of an integer. Example 1: Example 2: Example
阅读全文
摘要:http://poj.org/problem?id=3660 N (1 ≤ N ≤ 100) cows, conveniently numbered 1..N, are participating in a programming contest. As we all know, some cows
阅读全文
摘要:https://leetcode.com/problems/two-sum/description/ Given an array of integers, return indices of the two numbers such that they add up to a specific t
阅读全文