![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
ACM
NominationP
一切都是最好的安排
展开
-
codeforce 69D
#include<iostream> #include<vector> #include<math.h> #include<algorithm>//输入保证初始点到原点距离小于d,判断的是移动点到原点的距离(不是初始点)//将所有向量先排序(从大到小),然后依次取出,若所有选择都失败,则跳出,如果当时是A赢,那么A赢,如果是B赢,那么进入A的下一个选择,A有N次机会using namespace s原创 2016-08-29 12:14:15 · 470 阅读 · 0 评论 -
27. Remove Element
Given an array and a value, remove all instances of that value in place and return the new length. 给定一个数组和一个值,删除该值的所有实例,并返回新的长度。 Do not allocate extra space for another array, you must do this in pla原创 2016-05-02 22:59:51 · 182 阅读 · 0 评论 -
283. Move Zeroes
Given an array nums, write a function to move all 0’s to the end of it while maintaining the relative order of the non-zero elements.For example, given nums = [0, 1, 0, 3, 12], after calling your funct原创 2016-05-02 21:20:13 · 317 阅读 · 0 评论 -
226. Invert Binary Tree
Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9to 4 / \ 7 2 / \ / \ 9 6 3 1Trivia: This problem was inspired by this original tweet by Max Howell:Google: 90原创 2016-05-02 15:06:12 · 294 阅读 · 0 评论 -
204. Count Primes
Description:Count the number of prime numbers less than a non-negative number, n.计算比N小的所有质数的个数这道题花了好多时间,数学真实博大精深 ·.· 懵懂无知的我最开始是知道暴力求解是行不通的,然后发现第一种解法:把要除的所有比N小的数,变成了sqrt(n),直接少了一半,然后感慨了一番,结果。。。。这尽然是最最基原创 2016-05-01 23:25:15 · 358 阅读 · 0 评论 -
202. Happy Numbe
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原创 2016-05-01 09:34:39 · 360 阅读 · 0 评论 -
258. Add Digits
Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one digit, r原创 2016-04-30 09:44:21 · 347 阅读 · 0 评论 -
292. Nim Game
You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will be the原创 2016-04-30 07:56:09 · 355 阅读 · 0 评论 -
LeetCode345
Write a function that takes a string as input and reverse only the vowels of a string.Example 1: Given s = “hello”, return “holle”.Example 2: Given s = “leetcode”, return “leotcede”.vowel : 元音 0,0思路:原创 2016-04-26 22:49:50 · 485 阅读 · 0 评论 -
从单调栈到计算1的矩阵
从计算矩形的面积到计算1的矩阵计算矩形的最大面积#include <stdio.h> #include <stack> using namespace std; /** 单调递增栈,就最大矩形的面积 */ struct Node { long long height;//一个高度值 int startIdx; //这个高度值的起始位置 Node(long long _heigh转载 2016-04-26 20:21:16 · 427 阅读 · 0 评论 -
LeetCode197
Given a Weather table, write a SQL query to find all dates’ Ids with higher temperature compared to its previous (yesterday’s) dates.+---------+------------+------------------+ | Id(INT) | Date(DATE) |转载 2016-04-26 20:04:58 · 520 阅读 · 0 评论 -
codeforce 78E
思路:先用BFS找出炸弹到各个地方的时间再用BFS依次找出每个人(从它所在坐标 )在规定时间内能走到的所有坐标,以及到相应位置的时间 然后比较每个坐标,比较人所到的时间和炸弹到的时间,前者要比后者小才能通过,看这些合格的点中有没有救生胶囊,有的话就OK(这里的处理我代码上还有错,等有时间再改。。)正规的做法是先用BFS建图,然后用最大流计算 #include <stdio.h> #include原创 2016-08-29 20:28:52 · 393 阅读 · 0 评论 -
26. 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原创 2016-05-03 10:53:02 · 198 阅读 · 0 评论 -
203. 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思路1 为了最后能return修改后的链表,所以我们创建了一个总头dummy,来指向原创 2016-05-03 22:01:53 · 203 阅读 · 0 评论 -
350. Intersection of Two Arrays II
Given two arrays, write a function to compute their intersection.Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2].Note: Each element in the result should appear as many times as it原创 2016-07-03 21:26:35 · 286 阅读 · 0 评论 -
状态压缩DP
懂了就删#include <cstdio> #include <cstring> const int N = 13; const int M = 1<<N; const int mod = 100000000; int st[M],map[M]; ///分别存每一行的状态和给出地的状态 int dp[N][M]; //表示在第i行状态为j时候可以放牛的种数 bool judge1(int x)原创 2016-08-25 15:58:58 · 261 阅读 · 0 评论 -
10018 - 隔离圈
今天做了一道几何题,用到了凸包,求最小外接圆,判断点是否在多边形内。找了半天,记录一下 以下代码都是转载的,侵权即删凸包 求多边形的最小外接圆 判断点是否在多边形内 凸包求多边形的最小外接圆判断点是否在多边形内凸包 //二维点(或向量)结构体定义 //typedef vector<Point> vector<Point>; //判断两个点(或向量)是否相等 bool operator==(con原创 2016-08-22 22:43:36 · 682 阅读 · 0 评论 -
349. Intersection of Two Arrays
Given two arrays, write a function to compute their intersection.Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2].Note: Each element in the result must be unique. The result can be in原创 2016-07-03 19:46:21 · 314 阅读 · 0 评论 -
206. Reverse Linked List
Reverse a singly linked list. Hint: A linked list can be reversed either iteratively or recursively. Could you implement both? 思路1 自己想的,结果是超时,为什么会超时 >_< class Solution { public: ListNode* reverse原创 2016-05-09 23:09:19 · 270 阅读 · 0 评论 -
61. Rotate List
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->3->NULL. 思路 先求出尾节点以及链表大小,然后重新连接,感觉链表的链接还是很直观的。clas原创 2016-05-09 22:46:50 · 241 阅读 · 0 评论 -
229. Majority Element II
Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. The algorithm should run in linear time and in O(1) space.Hint: How many majority elements could it possibly ha原创 2016-05-09 14:26:03 · 249 阅读 · 0 评论 -
169. 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原创 2016-05-08 21:00:06 · 249 阅读 · 0 评论 -
217. Contains Duplicate
Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element is原创 2016-05-05 10:53:39 · 218 阅读 · 0 评论 -
171. Excel Sheet Column Number
Related to question Excel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For example A -> 1 B -> 2 C -> 3 ... Z -> 26原创 2016-05-04 22:31:24 · 181 阅读 · 0 评论 -
242. Valid Anagram
Given two strings s and t, write a function to determine if t is an anagram of s. 看一个数是不是另一个数的anagram anagram :组成元素相同,但顺序不同For example, s = “anagram”, t = “nagaram”, return true. s = “rat”, t = “c原创 2016-05-04 22:10:20 · 228 阅读 · 0 评论 -
DFS JAVA 模板
很好用import java.awt.*; import java.util.ArrayList;/** * Created by zhangzexiang on 2016/8/9. */ public class SmartRorbot_1048 {static int maxn=100; static boolean vst[][] = new boolean[maxn][maxn原创 2016-08-09 21:42:08 · 2408 阅读 · 0 评论