
Interesting questions
jimhust
这个作者很懒,什么都没留下…
展开
-
Can be divided by 3?
实现一个function,输入是一个string,string里的每一个字符都是‘0-9’,所以它每个substring都可以表示一个整数。输出其最长的可以被三整除的substring的长度。例如“1012300‘用range sum的idea,从左边开始往右边扫,一边扫一遍累加,把第一个出现mod3余1和mod3余2的和的下标存起来。然后当后面再出现余1或者余2的和的时候,就可以减去转载 2016-05-17 13:29:56 · 347 阅读 · 0 评论 -
Tricks in decide the index in the binary search with duplicate elements
First Position of TargetIf the array is [1, 2, 3, 3, 4, 5, 10], for given target 3, return 2.class Solution { /** * @param nums: The integer array. * @param target: Target to find.原创 2017-01-17 14:54:09 · 207 阅读 · 0 评论 -
Binary Indexed Tree
package com.interview.tree;/** * Date 04/27/2015 * @author tusroy * * Write a program to implement fenwick or binary indexed tree * * A Fenwick tree or binary indexed tree is a data structur转载 2017-03-02 11:04:54 · 268 阅读 · 0 评论