随笔分类 -  LeetCode

摘要:Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), ..., (an, bn) which makes sum of 阅读全文
posted @ 2017-04-27 11:01 sunli0205 阅读(204) 评论(0) 推荐(0)
摘要:1 public static void main(String[] args) { 2 char[] s ={'3', '2', '3', '^', '3','^', '1'}; 3 eatgold(s); 4 } 5 6 private static void eatgold(char[] value) { 7 ... 阅读全文
posted @ 2017-04-27 10:43 sunli0205 阅读(161) 评论(0) 推荐(0)
摘要:一个字符串中有多个个回文字符串: 阅读全文
posted @ 2017-03-24 09:24 sunli0205 阅读(135) 评论(0) 推荐(0)
摘要:Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements of [1, n] 阅读全文
posted @ 2017-03-23 21:36 sunli0205 阅读(87) 评论(0) 推荐(0)
摘要:Given a word, you need to judge whether the usage of capitals in it is right or not. We define the usage of capitals in a word to be right when one of 阅读全文
posted @ 2017-02-22 20:07 sunli0205 阅读(406) 评论(0) 推荐(0)
摘要:The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given two integers x and y, calcul 阅读全文
posted @ 2017-02-22 10:00 sunli0205 阅读(182) 评论(0) 推荐(0)
摘要:Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation. Note: Example 1: Exa 阅读全文
posted @ 2017-02-21 09:53 sunli0205 阅读(212) 评论(0) 推荐(0)
摘要:Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the 阅读全文
posted @ 2017-01-14 14:39 sunli0205 阅读(115) 评论(0) 推荐(0)
摘要:Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters. This 阅读全文
posted @ 2017-01-07 20:26 sunli0205 阅读(183) 评论(0) 推荐(0)
摘要:Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1. Examples: 分析:找出字符串中第一次出现且不重复的字符,返回 阅读全文
posted @ 2017-01-06 17:13 sunli0205 阅读(141) 评论(0) 推荐(0)
摘要:在链接列表中删除节点. 编写一个函数来删除单链表中的一个节点(除了尾部),只提供对该节点的访问.。假设链表是1 - > 2 - > 3 > 4,并给出了具有值为3的节点, 链表应该成为1 - > 2 - > 4 阅读全文
posted @ 2017-01-06 15:03 sunli0205 阅读(148) 评论(0) 推荐(0)
摘要:Find the sum of all left leaves in a given binary tree. 左树的值(9+15=24) 阅读全文
posted @ 2016-11-22 14:16 sunli0205 阅读(142) 评论(0) 推荐(0)