• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
neverlandly
博客园    首页    新随笔    联系   管理    订阅  订阅
2015年3月9日
Twitter OA prepare: Two Operations
摘要: 准备T家OA,网上看的面经最直接的方法,从target降到1,如果是奇数就减一,偶数就除2 1 public static void main(String[] args) { 2 int a = shortest(17); 3 System.out.println(a)... 阅读全文
posted @ 2015-03-09 11:54 neverlandly 阅读(681) 评论(0) 推荐(0)
Twitter OA prepare: even sum pairs
摘要: 思路:无非就是扫描一遍记录奇数和偶数各自的个数,比如为M和N,然后就是奇数里面选两个、偶数里面选两个,答案就是M(M-1)/2 + N(N-1)/2 阅读全文
posted @ 2015-03-09 11:51 neverlandly 阅读(477) 评论(0) 推荐(0)
Twitter OA prepare: K-complementary pair
摘要: 2sum的夹逼算法,需要sort一下。本身不难,但是tricky的地方在于允许同一个数组元素自己跟自己组成一个pair,比如上例中的[5, 5]。而且数组本身就允许值相等的元素存在,在计算pair时,算成不同的pair,比如数组是[3,3],K=6,这时的pair有[0, 0], [0, 1], [... 阅读全文
posted @ 2015-03-09 11:50 neverlandly 阅读(476) 评论(0) 推荐(0)
Twitter OA prepare: Anagram is A Palindrome
摘要: Algorithm:Count the number of occurrence of each character.Only one character with odd occurrence is allowed since in a palindrome maximum number of c... 阅读全文
posted @ 2015-03-09 11:47 neverlandly 阅读(400) 评论(0) 推荐(0)
Twitter OA prepare: Visit element of the array
摘要: 分析:就是建立一个boolean array来记录array里面每个元素的访问情况,遇到访问过的元素就停止visiting,返回未访问的结点个数 1 public int visiting(int[] A, int N) { 2 if (A==null || A.length==0) ret... 阅读全文
posted @ 2015-03-09 11:41 neverlandly 阅读(367) 评论(0) 推荐(0)
Lintcode: Longest Common Substring
摘要: Given two strings, find the longest common substring.Return the length of it.NoteThe characters in substring should occur continiously in original str... 阅读全文
posted @ 2015-03-09 11:33 neverlandly 阅读(454) 评论(0) 推荐(1)
Lintcode: Longest Common Subsequence
摘要: Given two strings, find the longest comment subsequence (LCS).Your code should return the length of LCS.ExampleFor "ABCD" and "EDCA", the LCS is "A" (... 阅读全文
posted @ 2015-03-09 08:11 neverlandly 阅读(741) 评论(0) 推荐(1)
Lintcode: Kth Prime Number (Original Name: Ugly Number)
摘要: Ugly number is a number that only have factors3,5and7.Design an algorithm to find the kth number such that the only prime factors are 3, 5, and 7.The ... 阅读全文
posted @ 2015-03-09 05:28 neverlandly 阅读(1536) 评论(0) 推荐(0)
Lintcode: Kth largest Element
摘要: Find K-th largest element in an array.NoteYou can swap elements in the arrayExampleIn array [9,3,2,4,8], the 3rd largest element is 4In array [1,2,3,4... 阅读全文
posted @ 2015-03-09 03:49 neverlandly 阅读(1620) 评论(0) 推荐(0)
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3