cKK

............当你觉得自己很辛苦,说明你正在走上坡路.............坚持做自己懒得做但是正确的事情,你就能得到别人想得到却得不到的东西............

导航

随笔分类 -  LeetCode

摘要:int search(int d[N][N], int key) { int i1, i2, j1, j2; i1 = j1 = 0; i2 = j2 = N-1; while(i1 < i2 && j1 < j2){ if(d[i1][j2] == key) return 1; if(d[i1][j2] < key)... 阅读全文

posted @ 2016-03-30 22:20 cKK 阅读(769) 评论(0) 推荐(0)

摘要:public static int MSA(int[] ar) { int[] arr = new int[ar.length]; int msa = 0; arr[0] = ar[0]; for (int i = 1; i = 0) arr[i] = arr[i - 1] + ar[i]; else arr[i] = ar[i]; } for (i... 阅读全文

posted @ 2016-03-27 01:37 cKK 阅读(203) 评论(0) 推荐(0)

摘要:public static int LIS(List al) { int[] arr = new int[al.size()]; int lis = 0; arr[0] = 1; for (int i = 1; i al.get(i - 1)) arr[i] = arr[i - 1] + 1; else arr[i] = 1; } for (in... 阅读全文

posted @ 2016-03-26 22:18 cKK 阅读(169) 评论(0) 推荐(0)

摘要:/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ 阅读全文

posted @ 2016-02-16 23:27 cKK 阅读(111) 评论(0) 推荐(0)

摘要:Given a sorted linked list, delete all duplicates such that each element appear only once. For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, 阅读全文

posted @ 2016-02-16 21:31 cKK 阅读(132) 评论(0) 推荐(0)

摘要:public void reverse (){ Node end =null,p,q; p=head; //p代表当前节点,end代表翻转后p后面的,q代表翻转前p后面的 while(p!=null){ //如果当前节点不为空 q=p.next; //q赋值为p后面的节点 p.next=end; / 阅读全文

posted @ 2016-02-16 14:41 cKK 阅读(272) 评论(0) 推荐(0)

摘要:Implement pow(x, n). double sum = 1; if (n > 0) { while ((n--) > 0) sum *= x; return sum; } else if (n < 0) { while ((n++) < 0) sum /= x; } return sum 阅读全文

posted @ 2016-01-27 16:31 cKK 阅读(243) 评论(0) 推荐(0)

摘要:Given a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.The brackets must close in the correct ... 阅读全文

posted @ 2016-01-27 13:16 cKK 阅读(196) 评论(0) 推荐(0)

摘要:Given a sorted array, remove the duplicates in place such that each element appear onlyonceand return the new length.Do not allocate extra space for a... 阅读全文

posted @ 2016-01-26 23:36 cKK 阅读(100) 评论(0) 推荐(0)

摘要:Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists./** * Def... 阅读全文

posted @ 2016-01-26 22:11 cKK 阅读(188) 评论(0) 推荐(0)

摘要:Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After ... 阅读全文

posted @ 2016-01-26 20:47 cKK 阅读(158) 评论(0) 推荐(0)

摘要:Write a function to find the longest common prefix string amongst an array of strings.Subscribe to see which companies asked this question }public cl... 阅读全文

posted @ 2016-01-26 15:11 cKK 阅读(151) 评论(0) 推荐(0)

摘要:/* Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Some hints:Could negative integers be palindromes?... 阅读全文

posted @ 2016-01-22 23:37 cKK 阅读(135) 评论(0) 推荐(0)

摘要:Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321click to show spoilers.Have you thought about this?Here are s... 阅读全文

posted @ 2016-01-22 00:43 cKK 阅读(162) 评论(0) 推荐(0)

摘要:Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.Example:Given nums = [-2, 0, 3, -5, 2, -1]sumRang... 阅读全文

posted @ 2016-01-21 16:08 cKK 阅读(205) 评论(0) 推荐(0)

摘要:/*Given an integer, write a function to determine if it is a power of three.Follow up:Could you do it without using any loop / recursion?*/public clas... 阅读全文

posted @ 2016-01-21 14:35 cKK 阅读(135) 评论(0) 推荐(0)

摘要:Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the... 阅读全文

posted @ 2016-01-20 22:01 cKK 阅读(143) 评论(0) 推荐(0)

摘要:/*Given two strings s and t, write a function to determine if t is an anagram of s.For example,s = "anagram", t = "nagaram", return true.s = "rat", t ... 阅读全文

posted @ 2015-09-17 21:26 cKK 阅读(463) 评论(0) 推荐(0)

摘要://Given an integer, write a function to determine if it is a power of two.public class isPowerOfTwo { public static boolean isPowerOfTwo(int n) { ... 阅读全文

posted @ 2015-09-17 21:19 cKK 阅读(184) 评论(0) 推荐(0)

摘要:注意:1.怎么至返回一次 2.循环里使用al.remove,al.size()也会变/*Given an array of integers, find two numbers such that they add up to a specific target number.The func... 阅读全文

posted @ 2015-06-04 13:44 cKK 阅读(227) 评论(0) 推荐(0)