惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
SegmentFault 最新的问题
月光博客
月光博客
大猫的无限游戏
大猫的无限游戏
GbyAI
GbyAI
博客园 - 叶小钗
小众软件
小众软件
WordPress大学
WordPress大学
I
InfoQ
Last Week in AI
Last Week in AI
Vercel News
Vercel News
博客园 - Franky
Stack Overflow Blog
Stack Overflow Blog
P
Proofpoint News Feed
A
About on SuperTechFans
Engineering at Meta
Engineering at Meta
腾讯CDC
D
DataBreaches.Net
有赞技术团队
有赞技术团队
宝玉的分享
宝玉的分享
Jina AI
Jina AI
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
G
Google Developers Blog
V
Visual Studio Blog
酷 壳 – CoolShell
酷 壳 – CoolShell

博客园 - HonestMan

面试百问 o,1的感悟 公司内部推荐 debain oracle insert method a linked list, find the node that the last node point to. Memory - HonestMan - 博客园 ShuffleMerge---microsoft's interview question 新手开始学习linux print all Permutation of a string An funy question! Google, hire me How to interview a programmer? Binary search tree convert to double linked list. Search in Binary tree spilt a list wirte a function for counting a linked list length Remove repeat char from a string
Get balance noe
HonestMan · 2007-09-24 · via 博客园 - HonestMan

a[0],a[1],a[2],a[1],a[1]
1      2     3     4      5   
balance noe is 3

C:

int BalanceNode(int *a, int length)
{
    int *begin=a, *end=a+length;
    int leftsum=0, rightsum=0;
    int position=0;

    while(position<length)
    {
        rightsum+=a[position];
        position++;
    }

    //begin compute
    position=0;
    while(begin<end)
    {
        if(leftsum==rightsum-a[position])
        return position;
        leftsum+=a[position];
        rightsum-=a[position];
        begin++;
        position++;
    }
    return -1;
}