![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
【 Interesting 】
文章平均质量分 95
Some interesting things.
东邪岛主止水
Take a step back. Look at the big picture.
展开
-
Gradle 学习
快速学习Gradle原创 2021-02-04 23:46:45 · 550 阅读 · 0 评论 -
[Codeforces]C. Tic-tac-toe
time limit per test: 1 second memory limit per test: 64 megabytes input: standard input output: standard outputCertainly, everyone is familiar with tic-tac-toe game. The rules are very simple i原创 2017-04-17 22:10:23 · 304 阅读 · 0 评论 -
[Codeforces]B. Lorry
time limit :per test2 seconds memory limit :per test64 megabytes inputstandard: input outputstandard: output A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to原创 2017-03-25 09:08:01 · 570 阅读 · 0 评论 -
[Codeforces]3A. Shortest path of the king
time limit :per test 1 second memory limit: per test64 megabytes input:standard input output:standard outputThe king is left alone on the chessboard. In spite of this loneliness, he doesn’t lose hea原创 2017-03-23 21:44:31 · 201 阅读 · 0 评论 -
[Codeforces]C. Commentator problem
The Olympic Games in Bercouver are in full swing now. Here everyone has their own objectives: sportsmen compete for medals, and sport commentators compete for more convenient positions to give a runnin原创 2017-03-23 13:58:40 · 227 阅读 · 0 评论 -
Single Number (I II III)
Single Number I Given an array of integers, every element appears twice except for one. Find that single one.Note: Your algorithm should have a linear runtime complexity. Could you implement it witho原创 2017-03-27 21:59:11 · 202 阅读 · 0 评论 -
Pascal's Triangle
Pascal’s Triangle IGiven 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] ]class Soluti原创 2017-03-28 20:21:46 · 191 阅读 · 0 评论 -
Search Insert Position
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the array.Here原创 2017-03-29 09:34:37 · 147 阅读 · 0 评论 -
Majority Element
Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the majority element always原创 2017-04-08 16:04:29 · 131 阅读 · 0 评论 -
Merge Sorted Array
Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.class Solution {public: void merge(vector<int>& nums1, int m, vector<int>& nums2, int n) { // num原创 2017-04-08 17:18:26 · 514 阅读 · 0 评论 -
Maximum Subarray
Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [-2,1,-3,4,-1,2,1,-5,4],the contiguous subarray [4,-1,2,1] has the l原创 2017-04-08 17:30:27 · 125 阅读 · 0 评论 -
Find All Numbers Disappeared in an Array
Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements of [1, n] inclusive that do not appear in this array.Could you原创 2017-04-08 18:08:41 · 166 阅读 · 0 评论 -
Plus One
Given a non-negative integer represented as a non-empty array of digits, plus one to the integer.You may assume the integer do not contain any leading zero, except the number 0 itself.The digits are st原创 2017-03-30 09:58:55 · 208 阅读 · 0 评论 -
Third Maximum Number
Given a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time complexity must be in O(n).Example 1: Input: [3, 2, 1]Outp原创 2017-03-30 10:04:07 · 128 阅读 · 0 评论 -
K-diff Pairs in an Array
Given an array of integers and an integer k, you need to find the number of unique k-diff pairs in the array. Here a k-diff pair is defined as an integer pair (i, j), where i and j are both numbers in原创 2017-04-09 13:42:54 · 209 阅读 · 0 评论 -
Remove Duplicates from Sorted Array
Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this in place with cons原创 2017-03-30 21:22:23 · 143 阅读 · 0 评论 -
Island Perimeter
You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water. Grid cells are connected horizontally/vertically (not diagonally). The grid is completely s原创 2017-04-09 20:15:26 · 120 阅读 · 0 评论 -
Number of Boomerangs
Given n points in the plane that are all pairwise distinct, a “boomerang” is a tuple of points (i, j, k) such that the distance between i and j equals the distance between i and k (the order of the tup原创 2017-04-09 21:18:36 · 154 阅读 · 0 评论 -
Find All Anagrams in a String Add to List
Given a string s and a non-empty string p, find all the start indices of p’s anagrams in s.Strings consists of lowercase English letters only and the length of both strings s and p will not be larger t原创 2017-04-09 21:59:12 · 108 阅读 · 0 评论 -
Longest Palindrome
Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters.This is case sensitive, for example “Aa” is not consider原创 2017-04-10 00:20:17 · 163 阅读 · 0 评论 -
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.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock), desi原创 2017-03-30 09:56:36 · 309 阅读 · 0 评论 -
Find the Difference
Given two strings s and t which consist of only lowercase letters.String t is generated by random shuffling string s and then add one more letter at a random position.Find the letter that was added in原创 2017-04-10 09:46:56 · 140 阅读 · 0 评论 -
Intersection of Two Arrays I II
Intersection of Two Arrays IGiven two arrays, write a function to compute their intersection.Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2]. 返回不允许重复!class Solution {public: vect原创 2017-04-10 10:03:39 · 271 阅读 · 0 评论 -
Keyboard Row
Given a List of words, return the words that can be typed using letters of alphabet on only one row’s of American keyboard like the image below.American keyboardExample 1: Input: [“Hello”, “Alaska”, “原创 2017-04-10 10:27:41 · 146 阅读 · 0 评论 -
Count Primes
Description:Count the number of prime numbers less than a non-negative number, n.方法:利用哈希查表法进行排除。class Solution {public: int countPrimes(int n) { vector<bool> vt(n,true); for(int i原创 2017-04-10 19:18:35 · 146 阅读 · 0 评论 -
Valid Anagram
Given two strings s and t, write a function to determine if t is an anagram of s.For example, s = “anagram”, t = “nagaram”, return true. s = “rat”, t = “car”, return false.方法:哈希class Solution {publi原创 2017-04-10 19:41:22 · 135 阅读 · 0 评论 -
Happy Number
Write an algorithm to determine if a number is “happy”.A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of i原创 2017-04-10 20:18:52 · 140 阅读 · 0 评论 -
Isomorphic Strings
Given two strings s and t, determine if they are isomorphic.Two strings are isomorphic if the characters in s can be replaced to get t.All occurrences of a character must be replaced with another chara原创 2017-04-10 20:54:06 · 109 阅读 · 0 评论 -
Linked List Cycle
Given a linked list, determine if it has a cycle in it.Follow up: Can you solve it without using extra space?方法:两个指针,一个指针走的快,一个指针走的慢,如果存在环,那么两个指针在行走时必相遇。/** * Definition for singly-linked list. * st原创 2017-04-10 22:25:40 · 112 阅读 · 0 评论 -
Delete Node in a Linked List
Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third node with value 3, t原创 2017-04-11 09:10:04 · 119 阅读 · 0 评论 -
Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear only once.For example, Given 1->1->2, return 1->2. Given 1->1->2->3->3, return 1->2->3./** * Definition for singly-lin原创 2017-04-11 09:16:58 · 121 阅读 · 0 评论 -
Intersection of Two Linked Lists
Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a1 → a2 ↘原创 2017-04-11 09:37:03 · 145 阅读 · 0 评论 -
Remove Linked List Elements
Remove all elements from a linked list of integers that have value val.Example Given: 1 –> 2 –> 6 –> 3 –> 4 –> 5 –> 6, val = 6 Return: 1 –> 2 –> 3 –> 4 –> 5/** * Definition for singly-linked list.原创 2017-04-11 14:32:34 · 101 阅读 · 0 评论 -
Reverse Linked List
Reverse a singly linked list./** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solutio原创 2017-04-11 20:19:58 · 102 阅读 · 0 评论 -
Palindrome Linked List
Given a singly linked list, determine if it is a palindrome.Follow up: Could you do it in O(n) time and O(1) space?方法:可以改变链表结构。/** * Definition for singly-linked list. * struct ListNode { * int原创 2017-04-11 20:54:08 · 111 阅读 · 0 评论 -
Merge Two Sorted Lists
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists./** * Definition for singly-linked list. * struct ListNode原创 2017-04-11 21:19:26 · 130 阅读 · 0 评论 -
Perfect Number
We define the Perfect Number is a positive integer that is equal to the sum of all its positive divisors except itself.Now, given an integer n, write a function that returns true when it is a perfect n原创 2017-04-11 22:09:51 · 152 阅读 · 0 评论 -
Minimum Moves to Equal Array Elements
Given a non-empty integer array of size n, find the minimum number of moves required to make all array elements equal, where a move is incrementing n - 1 elements by 1.Example:Input: [1,2,3]Output: 3原创 2017-04-11 22:19:54 · 115 阅读 · 0 评论 -
Roman to Integer
Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.class Solution {public: int romanToInt(string s) { unordered_map<char, int> m{{'I'原创 2017-04-11 22:37:29 · 120 阅读 · 0 评论 -
Arranging Coins
You have a total of n coins that you want to form in a staircase shape, where every k-th row must have exactly k coins.Given n, find the total number of full staircase rows that can be formed.n is a no原创 2017-04-12 10:19:59 · 156 阅读 · 0 评论