自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(12)
  • 收藏
  • 关注

翻译 Single Number

Given an array of integers, every element appears twice except for one. Find that single one.大意就是,别的数字都成双成对,只有一个数字孤身一人。【别名:寻找单身狗】Note:Your algorithm should have a linear runtime complexity

2015-09-30 10:13:03 258

原创 Remove Element 100%哟

Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn't matter what you leave beyond the new length.这

2015-09-17 14:31:05 287

原创 Reverse Linked List 翻转链表

Reverse a singly linked list.单向链表是个难点。一开始用栈来做,结果报了内存超过了。后来想到用指针来做。保存第二个元素的下一个节点,让他们依次反序指向即可/** * Definition for singly-linked list. * public class ListNode { * int val; *

2015-09-16 23:42:23 295 1

原创 Majority Element

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 array is non-empty and the majority element

2015-09-16 22:10:28 262 1

原创 Excel Sheet Column Number

Related to question Excel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For example: A -> 1 B -> 2 C -> 3 ...

2015-09-16 21:49:30 278

原创 最长单词

给一个词典,找出其中所有最长的单词样例在词典{ "dog", "google", "facebook", "internationalization", "blabla"}中, 最长的单词集合为 ["internationalization"]在词典{ "like", "love", "hate", "yes"}中

2015-09-11 11:12:50 315

原创 翻转二叉树

样例 1 1 / \ / \2 3 => 3 2 / \ 4 4通常使用递归的办法public class Solution { /** * @param root: a TreeNode, the root of the binary tree * @

2015-09-11 10:30:12 356 1

原创 O(1)检测2的幂次

用 O(1) 时间检测整数 n 是否是 2 的幂次。这个问题一开始我是想用求Log的方法算 public static boolean checkPowerOf2(int n) { // write your code here if(n<=0) return false; double answer=Math.log(n)/Ma

2015-09-11 09:53:53 423

原创 乱序字符串

给出一个字符串数组S,找到其中所有的乱序字符串(Anagram)。如果一个字符串是乱序字符串,那么他存在一个字母集合相同,但顺序不同的字符串也在S中。样例对于字符串数组 ["lint","intl","inlt","code"]返回 ["lint","inlt","intl"]注意所有的字符串都只包含小写字母先生成每个字符串的标识,即字母

2015-09-10 14:05:31 297

原创 比较两个字符串A和B,确定A中是否包含B中所有的字符。

如题样例给出 A = "ABCD" B = "ACD",返回 true给出 A = "ABCD" B = "AABC", 返回 false注意在 A 中出现的 B 字符串里的字符不需要连续或者有序。目前思路是分别扫描两个字符串得到两个map 比较字母出现次数,若A的每个字母次数都>=B , 则成立。同理 判断是否互为变位词也可

2015-09-09 14:08:35 6304 5

原创 JAVA GUI PART1 记事本程序 极其简易版

JMenuBar 菜单栏JMenu 菜单项JMenuItem 菜单项弹出来的子菜单项FileDialog 用来访问本地文件的对话框 (frame,string,int)以下为建议修改版记事本import java.awt.EventQueue;public class Textbook { private JFrame frame; JMenu mnFile

2014-01-25 21:21:25 741

原创 今天开始学JAVA

新学期开始了。。告别了C开始迎接JAVA,没想到光是一个输入数字问题就把我纠结了半天,网上的方法实在是太多了,我就稍微整理一下自己看到的方便我自己以后查吧- -!...1、   使用标准输入串对象System.inSystem.in.read()返回该字节数据的ascii码 其实我觉得不太好用啊= =2、 利用 Scanner 实现从键盘读入integer或floa

2013-03-07 18:57:46 392 1

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除