careercup专题

CareerCup Eliminate all ‘b’ and ‘ac’ in an array of characters

Eliminate all ‘b’ and ‘ac’ in an array of characters, you have to replace them in-place, and you are only allowed to iterate over the char array once. Examples: abc -> ac ac->'' rbact->rt -----------

CareerCup Rearrange an array using swap with 0

Rearrange an array using swap with 0.  You have two arrays src, tgt, containing two permutations of the numbers 0..n-1. You would like to rearrange src so that it equals tgt. The only allowed ope

CareerCup Pots of gold game:看谁拿的钱多

问题描述: Pots of gold game: Two players A & B. There are pots of gold arranged in a line, each containing some gold coins (the players can see how many coins are there in each gold pot - perfect inform

CareerCup View from the left and the right

You are given N blocks of height 1…N. In how many ways can you arrange these blocks in a row such that when viewed from left you see only L blocks (rest are hidden by taller blocks) and when seen from

CareerCup Trie Prefix Tree

Return a shortest prefix of <code>word</code> that is <em>not</em> a prefix of any word in the <code>list</code> e.g. word: cat, it has 4 prefixes: “”, “c”, “ca”, “cat” list: alpha, beta, cotton, delt

CareerCup Fork Problem

How many times “Hello World” is printed by following program?  int main()  {  if(fork() && fork())  {  fork();  }  if(fork() || fork())  {  fork();  }  printf(“Hello

CareerCup Add two number

Two numbers are represented as linked lists. Both lists are of same length. Add them without manipulating the lists and without a second traversal. ------------------------------------------------

CareerCup之2.2 寻找单链表倒数第n个元素

【题目】 原文: 2.2 Implement an algorithm to find the nth to last element of a singly linked list. 译文: 实现一个算法从一个单链表中返回倒数第n个元素。 【分析】 (1)创建两个指针p1和p2,指向单链表的开始节点。 (2)使p2移动n-1个位置,使之指向从头开始的第n个节点。(意思

CareerCup之2.1无序链表删除重复元素

【题目】 原文: 2.1 Write code to remove duplicates from an unsorted linked list. FOLLOW UP How would you solve this problem if a temporary buffer is not allowed? 译文: 从一个未排序的链表中移除重复的项 进一步地,

CareerCup之1.8 字符串移位包含问题

【题目】 原文: 1.8 Assume you have a method isSubstring which checks if one word is a substring of another. Given two strings, s1 and s2, write code to check if s2 is a rotation of s1 using only one c