摘要:
class Solution {public: void rotate(int nums[], int n, int k) { k%=n; reverse(nums,0,n-k-1); reverse(nums,n-k,n-1); rev... 阅读全文
摘要:
class Solution {public: int hammingWeight(uint32_t n) { int result=0; while(n){ n=n&(n-1); result++; ... 阅读全文
摘要:
public class Solution { public int rob(int[] nums) { int result=0; int rob=0; int unrob=0; for(int i=0;ib?a:b; }} 阅读全文
摘要:
public class Solution { public boolean isHappy(int n) { int sum=0; if(n==1||n==7) return true; else if(n>1&&n0){ ... 阅读全文
摘要:
/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */public... 阅读全文
摘要:
Description:Count the number of prime numbers less than a non-negative number,npublic class Solution { public int countPrimes(int n) { if(n(... 阅读全文