• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
neverlandly
博客园    首页    新随笔    联系   管理    订阅  订阅
上一页 1 ··· 12 13 14 15 16 17 18 19 20 21 下一页
2015年2月7日
Lintcode: Hash Function && Summary: Modular Multiplication, Addition, Power && Summary: 长整形long
摘要: In data structure Hash, hash function is used to convert a string(or any other type) into an integer smaller than hash size and bigger or equal to zer... 阅读全文
posted @ 2015-02-07 07:06 neverlandly 阅读(1765) 评论(1) 推荐(0)
Lintcode: Fizz Buzz
摘要: StringBuffer的用法,append方法的参数可以使boolean, char, char[], CharSequence, double, float, int, long, String, StringBuffer Better way: http://www.cnblogs.com/E 阅读全文
posted @ 2015-02-07 03:22 neverlandly 阅读(730) 评论(0) 推荐(0)
Lintcode: First Bad Version
摘要: The code base version is an integer and start from 1 to n. One day, someone commit a bad version in the code case, so it caused itself and the followi... 阅读全文
posted @ 2015-02-07 03:02 neverlandly 阅读(459) 评论(0) 推荐(0)
2015年2月6日
Lintcode: Find Peak Element
摘要: There is an integer array which has the following features: * The numbers in adjacent positions are different. * A[0] A[A.length - 1].We define... 阅读全文
posted @ 2015-02-06 13:21 neverlandly 阅读(347) 评论(0) 推荐(0)
Lintcode: Fast Power
摘要: Calculate the a^n % b where a, b and n are all 32bit integers.ExampleFor 2^31 % 3 = 2For 100^1000 % 1000 = 0ChallengeO(logn)这道题跟Pow这道题很像数学问题,要求O(log n... 阅读全文
posted @ 2015-02-06 12:10 neverlandly 阅读(944) 评论(0) 推荐(0)
Lintcode: Delete Digits
摘要: Given string A representative a positive integer which has N digits, remove any k digits of the number, the remaining digits are arranged according to... 阅读全文
posted @ 2015-02-06 06:24 neverlandly 阅读(2576) 评论(0) 推荐(1)
2015年2月5日
Lintcode: Digit Counts
摘要: Count the number of k's between 0 and n. k can be 0 - 9.Exampleif n=12, in [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], we have FIVE 1's (1, 10, 11, 12... 阅读全文
posted @ 2015-02-05 12:25 neverlandly 阅读(3330) 评论(0) 推荐(0)
Lintcode: Compare Strings
摘要: Compare two strings A and B, determine whether A contains all of the characters in B.The characters in string A and B are all Upper Case letters.Examp... 阅读全文
posted @ 2015-02-05 06:04 neverlandly 阅读(1383) 评论(0) 推荐(1)
Lintcode: First Position of Target (Binary Search)
摘要: Binary search is a famous question in algorithm.For a given sorted array (ascending order) and a target number, find the first index of this number in... 阅读全文
posted @ 2015-02-05 05:26 neverlandly 阅读(775) 评论(0) 推荐(0)
Lintcode: Binary Representation
摘要: Given a (decimal - e g 3.72) number that is passed in as a string,return the binary representation that is passed in as a string.If the number can no... 阅读全文
posted @ 2015-02-05 04:56 neverlandly 阅读(2021) 评论(0) 推荐(0)
2015年2月4日
Lintcode: Backpack II
摘要: Given n items with size A[i] and value V[i], and a backpack with size m. What's the maximum value can you put into the backpack?NoteYou cannot divide ... 阅读全文
posted @ 2015-02-04 14:36 neverlandly 阅读(2144) 评论(0) 推荐(1)
2015年2月3日
Lintcode: Backpack
摘要: Given n items with size A[i], an integer m denotes the size of a backpack. How full you can fill this backpack? NoteYou can not divide any item into s... 阅读全文
posted @ 2015-02-03 09:14 neverlandly 阅读(3805) 评论(2) 推荐(0)
Lintcode: A+B problem
摘要: For given numbers a and b in function aplusb, return the sum of them.NoteYou don't need to parse the input and output. Just calculate and return.Examp... 阅读全文
posted @ 2015-02-03 06:36 neverlandly 阅读(3932) 评论(0) 推荐(0)
2015年2月1日
Summary: Lowest Common Ancestor in a Binary Tree & Shortest Path In a Binary Tree
摘要: 转自:Pavel's BlogNow let's say we want to find the LCA for nodes 4 and 9, we will need to traverse the whole tree to compare each node so that we can lo... 阅读全文
posted @ 2015-02-01 13:25 neverlandly 阅读(535) 评论(0) 推荐(0)
Summary: Prime
摘要: 最近遇到很多问题都跟Prime有关,于是总结一下:Prime definition:Aprime number(or aprime) is anatural numbergreater than 1 that has no positivedivisorsother than 1 and itsel... 阅读全文
posted @ 2015-02-01 06:12 neverlandly 阅读(490) 评论(0) 推荐(0)
2015年1月29日
Summary: Java Inheritance
摘要: In this tutorial we will discuss about the inheritance in Java. The most fundamental element of Java is the class. A class represents an entity and al... 阅读全文
posted @ 2015-01-29 14:27 neverlandly 阅读(411) 评论(0) 推荐(0)
Summary: difference between public, default, protected, and private key words
摘要: According to Java Tutorial:Controlling Access to Members of a ClassAccess level modifiers determine whether other classes can use a particular field o... 阅读全文
posted @ 2015-01-29 14:20 neverlandly 阅读(333) 评论(0) 推荐(0)
Summary: Arrays vs. Collections && The differences between Collection Interface and Collections Class
摘要: 转自http://www.anylogic.com/anylogic/help/index.jsp?topic=/com.xj.anylogic.help/html/code/Arrays_Collections.htmlJava offers two types of constructs whe... 阅读全文
posted @ 2015-01-29 09:00 neverlandly 阅读(302) 评论(0) 推荐(0)
Leetcode: Largest Number
摘要: 聪明方法:其实干嘛要挨个比呢,按最直接的方法,接起来,谁大谁在前: 可以换一下思路,要想比较两个数在最终结果中的先后位置,何不直接比较一下不同组合的结果大小? 举个例子:要比较3和34的先后位置,可以比较334和343的大小,而343比334大,所以34应当在前。 这样,有了比较两个数的方法,就可以 阅读全文
posted @ 2015-01-29 07:31 neverlandly 阅读(479) 评论(0) 推荐(1)
Leetcode: Dungeon Game
摘要: The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a... 阅读全文
posted @ 2015-01-29 00:07 neverlandly 阅读(717) 评论(0) 推荐(0)
2015年1月28日
Leetcode: Binary Search Tree Iterator
摘要: Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Calling next() will return the ne... 阅读全文
posted @ 2015-01-28 07:36 neverlandly 阅读(534) 评论(0) 推荐(0)
2015年1月27日
Leetcode: Two Sum III - Data structure design
摘要: The trade off should be considered: In fact, there has to be one operation's time complexity is O(n) and the other is O(1), no matter add or find. So 阅读全文
posted @ 2015-01-27 12:51 neverlandly 阅读(3524) 评论(0) 推荐(0)
Leetcode: Two Sum II
摘要: Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.The function ... 阅读全文
posted @ 2015-01-27 12:02 neverlandly 阅读(400) 评论(0) 推荐(0)
Leetcode: Fraction to Recurring Decimal
摘要: Given two integers representing the numerator and denominator of a fraction, return the fraction in string format.If the fractional part is repeating,... 阅读全文
posted @ 2015-01-27 09:10 neverlandly 阅读(391) 评论(0) 推荐(0)
Leetcode: Compare Version Numbers
摘要: 这道题的意思用一个例子说明就是1.2 < 1.10, 因为1.10跟1.1是不一样的,1.10代表tenth revision. 而1.1代表first revision。所以这道题要按“.”分段,然后分段比较,方法是用split函数把string 分段,每一段挨个比过去。这里参考了网上的一个小技巧 阅读全文
posted @ 2015-01-27 05:09 neverlandly 阅读(461) 评论(0) 推荐(0)
2015年1月26日
Leetcode: Maximum Gap
摘要: Given an unsorted array, find the maximum difference between the successive elements in its sorted form.Try to solve it in linear time/space.Return 0 ... 阅读全文
posted @ 2015-01-26 12:49 neverlandly 阅读(330) 评论(0) 推荐(0)
Leetcode: Missing Ranges
摘要: 第二遍做法:参考下面一个vimukthi的解答 https://discuss.leetcode.com/topic/18612/accepted-java-solution-with-explanation/3 low 表示next possible missing integer streak的 阅读全文
posted @ 2015-01-26 10:31 neverlandly 阅读(793) 评论(0) 推荐(0)
2015年1月24日
Leetcode: One Edit Distance
摘要: 注意这道题:Must be exactly one distance apart. Not the same. 另外FB面经有一道比较狠的这个题的变形: 这题就是one edit distance的变形题,难点在于给的Iterator,事先不知道两个file的长度,也不允许用extra space( 阅读全文
posted @ 2015-01-24 05:46 neverlandly 阅读(1285) 评论(0) 推荐(0)
2015年1月22日
Leetcode: Longest Substring with At Most Two Distinct Characters
摘要: 方法一:用HashMap, map里面存元素及其出现次数。维护一个最大长度。用两个指针,右指针一直走到出现3个dinstinct character为止。然后调整左指针删元素,直接从左往右逐个字符的删除,一直删到某个字符不会再出现。判断字符被删光就看次数是否减为了0. 采用方法: 这里每个元素都会进 阅读全文
posted @ 2015-01-22 13:17 neverlandly 阅读(400) 评论(0) 推荐(0)
Leetcode: Read N Characters Given Read4 II - Call multiple times
摘要: 这道题跟I不一样在于,read函数可能多次调用,比如read(buf,23)之后又read(buf, 25), 第一次调用时的buffer还没用完,还剩一个char在buffer里,第二次拿出来接着用,这样才能保证接着上次读的地方继续往下读。 1. 所以应该设置这4个char的buffer为inst 阅读全文
posted @ 2015-01-22 07:35 neverlandly 阅读(2821) 评论(0) 推荐(0)
Summary: Stack Overflow Error
摘要: What is a stack overflow error?Parameters and local variables are allocated on the stack (with reference types the object lives on the heap and a vari... 阅读全文
posted @ 2015-01-22 06:47 neverlandly 阅读(338) 评论(0) 推荐(0)
2015年1月19日
Leetcode: Read N Characters Given Read4
摘要: 说明:1. read4(char * buf)的这个buf起初是空的,然后read4读出来的东西存在这个buf里; 2. read函数的buf是destination, 是我们需要往里面依次写通过read4读出来的东西 首先read4是一个读文件的函数,只能读4个char。 char [] buff 阅读全文
posted @ 2015-01-19 13:08 neverlandly 阅读(608) 评论(0) 推荐(0)
Leetcode: Binary Tree Upside Down
摘要: 这题第一眼看上去觉得没头绪,不知道怎么上下翻转和左右翻转。但在纸上画几个例子就清楚了。所有的右子树要么为空、要么就是叶子节点且有左子树存在。 那么原来的数一直沿左子树走下去最左的那个节点就是新树的根节点。 这道题最关键在于想到要用递归去做!这种树的结构、父子两层节点关系的问题多半都要用递归去做。这是 阅读全文
posted @ 2015-01-19 07:57 neverlandly 阅读(1262) 评论(0) 推荐(1)
2015年1月7日
Leetcode: 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 阅读全文
posted @ 2015-01-07 11:39 neverlandly 阅读(327) 评论(0) 推荐(0)
Leetcode: Factorial Trailing Zeroes
摘要: Given an integer n, return the number of trailing zeroes in n!.Note: Your solution should be in logarithmic time complexity.Naive方法:A simple method is... 阅读全文
posted @ 2015-01-07 07:22 neverlandly 阅读(2096) 评论(0) 推荐(0)
2015年1月4日
Twitter OA prepare: Rational Sum
摘要: In mathematics, a rational number is any number that can be expressed in the form of a fraction p/q , where p & q are two integers, and the denominato... 阅读全文
posted @ 2015-01-04 08:30 neverlandly 阅读(500) 评论(0) 推荐(0)
Java: Best Way to read a file
摘要: 经常在各种平台的online test里面不熟悉STDIN, STOUT,下面举个例子: Input Format There are three lines of input: The first line contains an integer. The second line contains 阅读全文
posted @ 2015-01-04 08:18 neverlandly 阅读(246) 评论(0) 推荐(0)
2015年1月3日
Summary: gcd最大公约数、lcm最小公倍数算法
摘要: 欧几里德算法欧几里德算法又称辗转相除法,用于计算两个整数a,b的最大公约数。其计算原理依赖于下面的定理:定理:gcd(a,b) = gcd(b,a mod b)证明:a可以表示成a = kb + r,则r = a mod b假设d是a,b的一个公约数,则有d|a, d|b,而r = a - kb,因... 阅读全文
posted @ 2015-01-03 23:42 neverlandly 阅读(1425) 评论(0) 推荐(0)
Twitter OA prepare: Flipping a bit
摘要: You are given a binary array with N elements: d[0], d[1], ... d[N - 1]. You can perform AT MOST one move on the array: choose any two integers [L, R],... 阅读全文
posted @ 2015-01-03 04:52 neverlandly 阅读(687) 评论(0) 推荐(0)
Twitter OA prepare: Equilibrium index of an array
摘要: Equilibrium index of an array is an index such that the sum of elements at lower indexes is equal to the sum of elements at higher indexes. For exampl... 阅读全文
posted @ 2015-01-03 04:18 neverlandly 阅读(480) 评论(0) 推荐(0)
上一页 1 ··· 12 13 14 15 16 17 18 19 20 21 下一页
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3