上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 18 下一页
摘要: 题目描述:Reverse a singly linked list.解题思路:使用递归或者迭代的方法。代码如下:方法一:递归/** * Definition for singly-linked list. * public class ListNode { * int val; * ... 阅读全文
posted @ 2015-12-28 13:24 scottwang 阅读(170) 评论(0) 推荐(0) 编辑
摘要: 题目描述:Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as theHamming weight).For example, the 32-b... 阅读全文
posted @ 2015-12-28 12:32 scottwang 阅读(306) 评论(0) 推荐(0) 编辑
摘要: 题目描述:Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to thedefinition of LCA on Wikipe... 阅读全文
posted @ 2015-12-25 16:46 scottwang 阅读(340) 评论(0) 推荐(0) 编辑
摘要: 题目描述:Given an array of sizen, find the majority element. The majority element is the element that appears more than⌊ n/2 ⌋times.You may assume that th... 阅读全文
posted @ 2015-12-24 23:06 scottwang 阅读(186) 评论(0) 推荐(0) 编辑
摘要: 题目描述:A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -> 28 解题思路:循环读取数字,从左向右读取,每次该位字符减去A加上一即为该为数字代表的数值,然后每次循环前将之前的结果乘以26.表示该表示为26进制。代码如下... 阅读全文
posted @ 2015-12-24 19:07 scottwang 阅读(192) 评论(0) 推荐(0) 编辑
摘要: 题目描述:Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in th... 阅读全文
posted @ 2015-12-24 09:18 scottwang 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 题目描述:Given two stringssandt, write a function to determine iftis an anagram ofs.For example,s= "anagram",t= "nagaram", return true.s= "rat",t= "car", ... 阅读全文
posted @ 2015-12-23 23:25 scottwang 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 题目描述: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 identic... 阅读全文
posted @ 2015-12-23 15:01 scottwang 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 题目描述:Given a non-negative integernum, repeatedly add all its digits until the result has only one digit.For example:Givennum = 38, the process is like... 阅读全文
posted @ 2015-12-22 09:50 scottwang 阅读(268) 评论(0) 推荐(0) 编辑
摘要: 题目描述: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 farthe... 阅读全文
posted @ 2015-12-22 09:48 scottwang 阅读(260) 评论(0) 推荐(0) 编辑
上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 18 下一页