【Leetcode_easy】997. Find the Town Judge

【Leetcode_easy】997. Find the Town Judge的相关文章

【HDU5391】Zball in Tina Town

[题目大意] 一个球初始体积为1,一天天变大,第一天变大1倍,第二天变大2倍,第n天变大n倍.问当第 n-1天的时候,体积变为多少.注意答案对n取模. [题解] 根据威尔逊定理:(n-1)! mod n =-1 所以当n为质数时,答案就是n-1 否则答案显然是0 注意4要特判一下,ans[4]=2 这里有一种很魔性的判素数的方法,详见代码 1 /************* 2 HDU 5391 3 by chty 4 2016.11.4 5 *************/ 6 #include<i

#Leetcode# 997. Find the Town Judge

https://leetcode.com/problems/find-the-town-judge/ In a town, there are N people labelled from 1 to N.  There is a rumor that one of these people is secretly the town judge. If the town judge exists, then: The town judge trusts nobody. Everybody (exc

【leetcode_easy】543. Diameter of Binary Tree

problem 543. Diameter of Binary Tree 参考 1. Leetcode_easy_543. Diameter of Binary Tree; 完 原文地址:https://www.cnblogs.com/happyamyhope/p/10943221.html

【leetcode_easy】551. Student Attendance Record I

problem 551. Student Attendance Record I 参考 1. Leetcode_easy_551. Student Attendance Record I; 完 原文地址:https://www.cnblogs.com/happyamyhope/p/10947954.html

【Leetcode_easy】599. Minimum Index Sum of Two Lists

problem 599. Minimum Index Sum of Two Lists 参考 1. Leetcode_easy_599. Minimum Index Sum of Two Lists; 完 原文地址:https://www.cnblogs.com/happyamyhope/p/11059712.html

【Leetcode_easy】617. Merge Two Binary Trees

problem 617. Merge Two Binary Trees 参考 1. Leetcode_easy_617. Merge Two Binary Trees; 完 原文地址:https://www.cnblogs.com/happyamyhope/p/11076297.html

【Leetcode_easy】682. Baseball Game

problem 682. Baseball Game 参考 1. Leetcode_easy_682. Baseball Game; 完 原文地址:https://www.cnblogs.com/happyamyhope/p/11091366.html

【Leetcode_easy】680. Valid Palindrome II

problem 680. Valid Palindrome II 参考 1. Leetcode_easy_680. Valid Palindrome II; 完 原文地址:https://www.cnblogs.com/happyamyhope/p/11091358.html

【Leetcode_easy】766. Toeplitz Matrix

problem 766. Toeplitz Matrix solution1: class Solution { public: bool isToeplitzMatrix(vector<vector<int>>& matrix) { for(int i=0; i<matrix.size()-1; ++i) { for(int j=0; j<matrix[0].size()-1; ++j) { if(matrix[i][j] != matrix[i+1][j+1