摘要:
Given an array of integers and an integerk, find out whether there there are two distinct indicesiandjin the array such thatnums[i] = nums[j]and the d... 阅读全文
摘要:
Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Follow up:Can you solve it without using extra space?/**... 阅读全文
摘要:
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. *... 阅读全文
摘要:
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(... 阅读全文
摘要:
package my0414;import java.io.UnsupportedEncodingException;public class StringText { /** * @param args * @throws UnsupportedEncodingException */ p... 阅读全文