- 博客(9)
- 资源 (4)
- 收藏
- 关注
原创 [LeetCode]ZigZag Conversion
题目:点击打开链接 public class Solution { public String convert(String s, int numRows) { if (1 >= numRows) { return s; } int length = s.length();
2015-10-09 08:34:24 233
原创 [LeetCode]Longest Palindromic Substring
题目:点击打开链接 public class Solution { public String longestPalindrome(String s) { if (null == s) { return null; } int length = s.length(); if
2015-10-09 08:32:21 189
原创 [LeetCode]Median of Two Sorted Arrays
题目:点击打开链接 public class Solution { public double findMedianSortedArrays(int[] nums1, int[] nums2) { if ((null == nums1) || (null == nums2)) { return 0; } int t
2015-10-08 16:39:28 227
原创 [LeetCode]Longest Substring Without Repeating Characters
题目:点击打开链接 public class Solution { public int lengthOfLongestSubstring(String s) { if (null == s) { return 0; } int length = s.length(); if (1
2015-10-08 16:38:13 286
原创 [LeetCode]Add Two Numbers
题目:点击打开链接 /** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */ public class Solution { public Li
2015-10-08 16:37:10 247
原创 [LeetCode]Two Sum
题目:点击打开链接 public class Solution { public int[] twoSum(int[] nums, int target) { if (null == nums) { return null; } int length = nums.length; if (0
2015-10-08 16:13:41 232
原创 快速幂
题目:求 a^n % p。 分析:a^n = a^(2^0 * n[0] + 2^1 * n[1] + 2^2 * n[2] + ... + 2^(t-1) * n[t-1]) = (a^(2^0))^n[0] * (a^(2^1))^n[1] * (a^(2^2))^n[2] * ... * (a^(2^(t-1)))^n[t-1] ...
2015-06-26 17:02:15 80
原创 不使用加减乘除的加法
int add(int a, int b) { int c; while (0 != b) { c = a ^ b; b = (a & b) << 1; a = c; } return a; }
2015-06-26 16:01:38 76
原创 不申请空间的两数交换
方法一: void swap(int& a, int& b) { a = a + b; b = a - b; a = a - b; } 方法二: void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; } ...
2015-06-26 15:30:20 108
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人