- 博客(12)
- 收藏
- 关注
转载 Java中ArrayList类的用法(转)
1、什么是ArrayList ArrayList就是传说中的动态数组,用MSDN中的说法,就是Array的复杂版本,它提供了如下一些好处: 动态的增加和减少元素 实现了ICollection和IList接口 灵活的设置数组的大小 2、如何使用ArrayList 最简单的例子: ArrayList List = new ArrayList(); for( int i=0
2016-06-16 03:47:43 183
原创 Leetcode 171. Excel Sheet Column Number
Related to question Excel Sheet Column Title Given a column title as appear in an Excel sheet, return its corresponding column number. For example: A -> 1 B -> 2 C -> 3 ...
2016-06-04 13:45:25 175
原创 Leetcode 206. Reverse Linked List
Reverse a singly linked list. 我的代码 如果拉掉注释那一句,那么链表末尾会形成一个圈,超时 public class Solution { public ListNode reverseList(ListNode head) { ListNode before, now, after; before = head;
2016-06-04 13:25:36 174
原创 Leetcode 235. Lowest Common Ancestor of a Binary Search Tree
Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined betw
2016-06-04 12:30:04 178
原创 Leetcode 13. Roman to Integer
Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 附罗马换算算法 I 1 IV 4 V-I V 5 IX 9 X-I X 10 XL 40 L-X L
2016-06-04 09:40:06 167
原创 Leetcode 100. Same Tree
Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurally identical and the nodes have the same value. 我的代码: p
2016-06-02 02:31:51 157
原创 Leetcode 237. Delete Node in a Linked List
Write a function to delete a node (except the tail) in a singly linked list, given only access to that node. Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third node with value
2016-06-01 14:46:49 175
原创 Leetcode 283. Move Zeroes
Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements. For example, given nums = [0, 1, 0, 3, 12], after calling you
2016-06-01 14:18:36 177
原创 Leetcode 226. Invert Binary Tree
Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1 /** * Definition for a binary tree node. * public class TreeNode {
2016-05-31 15:07:39 155
转载 Leetcode 104. Maximum Depth of Binary Tree
Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. /** * Definition for a binary t
2016-05-31 14:11:51 257
原创 Leetcode 258. Add Digits
Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. For example: Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has
2016-05-31 11:50:09 192
原创 leetcode 344 Reverse String
Write a function that takes a string as input and returns the string reversed. Example: Given s = "hello", return "olleh". 我的解法 public class Solution { public String reverseString(Strin
2016-05-30 13:25:32 183
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人