All posts by jshi

Oil prices steady as Japan emerges from recession

$2.55  Already Paid?
SINGAPORE  – Oil □□□□□□ □□□□ steady on Monday, with traders □□□□□□ the recent upward □□□□□□□□ was continuing as Japan □□□□□□□ from recession and after U.S. oil drilling fell. Japan’s economy rebounded from recession in the □□□□□ quarter, and although the data was □□□□□□ than expected, the return to growth of Asia’s second biggest □□□□□□□ and energy user lent oil support, analysts said. Benchmark Brent crude □□□□□□□ □□□□ trading at □□□□□□ per barrel at □□□□ GMT □□□□□ p.m. EST Sunday), virtually level with their □□□□ settlement. U.S. WTI crude □□□ also flat at □□□□□□ a barrel. Oil □□□□□□□ rose strongly □□□□ □□□□□□ after another □□□□ in the □□□□ rig count, pushing Brent back above □□□ a □□□□□□ for the □□□□□ □□□□ since □□□□□□□□ last year. In related news, Brent falls below □□□ as Japan enters recession.

Longest Palindromic Substring

$2.55  Already Paid?
$2.55  Already Paid?
http://leetcode.com/2011/11/longest-palindromic-substring-part-ii.html

Longest □□□□□□□□□□□ Substring Part □□

□□□□□□□□ □□□ □□□□ in string

Given a string S, find the □□□□□□□ palindromic substring in S.

Note:
This □□ Part □□ of the article: Longest □□□□□□□□□□□ □□□□□□□□□□ Here, we □□□□□□□□ an □□□□□□□□□ (Manacher’s algorithm) which □□□□□ the □□□□□□□ palindromic substring in linear time. Please read Part I for more □□□□□□□□□□ information.

In my □□□□□□□□ □□□□ we □□□□□□□□□ a total of □□□□ □□□□□□□□□ methods, among them there’s a pretty □□□□□□ algorithm with O(N2) run □□□□ and □□□□□□□□ □□□□□ complexity. Here, we discuss an algorithm that □□□□ in O(N) □□□□ and O(N) space, also □□□□□ as Manacher’s algorithm.

Hint:
Think how you would □□□□□□□ over the simpler O(N2) approach. Consider the □□□□□ □□□□ scenarios. The □□□□□ □□□□ □□□□□□□□□ □□□ the □□□□□□ with multiple □□□□□□□□□□□ overlapping each other. For example, the inputs: “aaaaaaaaa” and “cabcbabcbabcba”. In fact, we could □□□□ □□□□□□□□□ of the palindrome’s □□□□□□□□□ □□□□□□□□ and avoid some of the □□□□□□□□□□□ computations.

An O(N) Solution (Manacher’s Algorithm):
First, we transform the □□□□□ string, S, to another string T by □□□□□□□□□ a □□□□□□□ □□□□□□□□□ ‘#’ in between letters. The □□□□□□ for □□□□□ so will □□ immediately clear to you soon.

For example: S = “abaaba”, T = “#a#b#a#a#b#a#”.

To find the □□□□□□□ palindromic substring, we □□□□ to □□□□□□ around each Ti such that Ti-d … Ti+d forms a palindrome. You should immediately □□□ that d □□ the □□□□□□ of the palindrome itself centered at Ti.

We store intermediate □□□□□□ in an □□□□□ P, where P[ i ] equals to the □□□□□□ of the □□□□□□□□□□ centers at Ti. The □□□□□□□ palindromic substring would then □□ the maximum □□□□□□□ in P.

Using the above example, we populate P as below (from left to right):

T = # a # b # a # a # b # a #
P = 0 1 0 3 0 1 6 1 0 3 0 1 0

Looking at P, we immediately see that the □□□□□□□ □□□□□□□□□□ □□ “abaaba”, as □□□□□□□□□ by P6 = 6.

Did you notice by □□□□□□□□□ □□□□□□□ □□□□□□□□□□ □□□ in between letters, both □□□□□□□□□□□ of □□□ and even □□□□□□□ are □□□□□□□ graciously? (Please note: This □□ to □□□□□□□□□□□ the □□□□ more easily and □□ not necessarily needed to code the algorithm.)

Now, imagine that you draw an imaginary □□□□□□□□ □□□□ at the □□□□□□ of the palindrome “abaaba”. □□□ you notice the □□□□□□□ in P are symmetric around this □□□□□□□ That’s not only it, try another palindrome “aba”, the □□□□□□□ also □□□□□□□ □□□□□□□ symmetric □□□□□□□□□ □□ this a coincidence? The □□□□□□ □□ yes and no. This □□ only □□□□ subjected to a condition, but anyway, we □□□□ great progress, since we can □□□□□□□□□ recomputing □□□□ of P[ i ]‘s.

Let us move on to a slightly more □□□□□□□□□□□□□ □□□□□□□ with more some overlapping palindromes, where S = “babcbabcbaccba”.


Above □□□□□ shows T transformed from S = “babcbabcbaccba”. Assumed that you □□□□□□□ a □□□□□ where table P □□ partially completed. The □□□□□ □□□□□□□□ □□□□ □□□□□□□□□ the □□□□□□ (C) of the palindrome “abcbabcba”. The □□□ dotted □□□□□□□□ □□□□ indicate its left (L) and right (R) edges respectively. You □□□ at index i and its mirrored □□□□□ around C □□ i’. How would you □□□□□□□□□ P[ i ] efficiently?

Assume that we □□□□ arrived at index i = □□□ and we need to □□□□□□□□□ P[ □□ ] □□□□□□□□□□ by the □□□□□□□□ mark ?). We first look at its mirrored □□□□□ i’ around the palindrome’s center C, which □□ index i’ = □□


The □□□ green solid □□□□□ above indicate the covered □□□□□□ by the □□□ □□□□□□□□□□□ centered at i and i’. We look at the mirrored □□□□□ of i around C, which □□ index i’. P[ i' ] = P[ 9 ] = □□ It □□ □□□□□ that P[ i ] must also □□ □□ □□□ to the □□□□□□□□□ □□□□□□□□ of a □□□□□□□□□□ around its center.

As you can □□□ above, it □□ very □□□□□□□ that P[ i ] = P[ i' ] = □□ which must □□ □□□□ due to the □□□□□□□□□ □□□□□□□□ around a palindrome’s center. In fact, all □□□□□ □□□□□□□□ after C follow the □□□□□□□□□ □□□□□□□□ (that is, P[ □□ ] = P[ □□ ] = □□ P[ □□ ] = P[ 9 ] = □□ P[ □□ ] = P[ 8 ] = 0).


Now we □□□ at index i = □□□ and its mirrored □□□□□ around C □□ i’ = □□ □□ P[ □□ ] = P[ 7 ] = □□

Now we □□□ at index i = 15. What’s the □□□□□ of P[ i ]? If we □□□□□□ the symmetric property, the □□□□□ of P[ i ] should □□ the □□□□ as P[ i' ] = □□ But this □□ wrong. If we expand around the □□□□□□ at T15, it forms the palindrome “a#b#c#b#a”, which □□ actually shorter than what □□ □□□□□□□□□ by its □□□□□□□□□ counterpart. Why?


Colored □□□□□ □□□ □□□□□□□□ around the □□□□□□ at □□□□□ i and i’. Solid green □□□□□ show the □□□□□□ that must □□□□□ for both □□□□□ due to symmetric □□□□□□□□ around □□ Solid red □□□□□ show the □□□□□□ that might not □□□□□ for both sides. Dotted green □□□□□ show the □□□□□□ that □□□□□□□ over the center.

It □□ □□□□□ that the □□□ □□□□□□□□□□ in the □□□□□□ indicated by the □□□ □□□□□ green □□□□□ must □□□□□ exactly. Areas across the □□□□□□ (indicated by dotted green lines) must also □□ symmetric. Notice carefully that P[ i ' ] □□ 7 and it □□□□□□□ all the □□□ across the left □□□□ (L) of the palindrome (indicated by the □□□□□ red lines), which □□□□ not □□□□ under the □□□□□□□□□ □□□□□□□□ of the □□□□□□□□□□ anymore. All we □□□□ □□ P[ i ] ≥ □□ and to □□□□ the □□□□ □□□□□ of P[ i ] we □□□□ to □□ character matching by □□□□□□□□□ past the right □□□□ (R). In this case, since P[ □□ ] ≠ P[ 1 ], we □□□□□□□□ that P[ i ] = 5.

Let’s summarize the key □□□□ of this algorithm as below:

if P[ i' ] ≤ R – i,
then P[ i ] ← P[ i' ]
else P[ i ] ≥ P[ i' □□ (Which we □□□□ to □□□□□□ past the right □□□□ (R) to □□□□ P[ i ].

See how □□□□□□□ it is? If you □□□ □□□□ to □□□□□ the above □□□□□□□ fully, you already □□□□□□□□ the □□□□□□□ of this algorithm, which □□ also the hardest part.

The □□□□□ □□□□ □□ to □□□□□□□□□ when should we move the □□□□□□□□ of C together with R to the right, which □□ easy:

If the palindrome centered at i □□□□ expand past R, we update C to i, (the □□□□□□ of this □□□ palindrome), and extend R to the □□□ palindrome’s right edge.

In each step, there □□□ □□□ possibilities. If P[ i ] ≤ R – i, we set P[ i ] to P[ i' ] which □□□□□ exactly □□□ step. Otherwise we attempt to □□□□□□ the palindrome’s center to i by □□□□□□□□□ it □□□□□□□□ at the right edge, R. Extending R (the inner while loop) takes at most a total of N □□□□□□ and positioning and testing each □□□□□□□ □□□□ a total of N steps too. Therefore, this algorithm guarantees to □□□□□□ in at □□□□ 2*N steps, □□□□□□ a linear □□□□ solution.

Note:
This □□□□□□□□□ □□ definitely □□□□□□□□□□□ and you won’t be □□□□□□□□ to □□□□ up with □□□□ □□□□□□□□□ during an □□□□□□□□□ setting. However, I □□ hope that you enjoy □□□□□□□ this □□□□□□□ and hopefully it □□□□□ you in understanding this interesting algorithm. You □□□□□□□ a □□□ if you □□□□ □□□□ this far! :)

Further Thoughts:

  • In fact, there □□□□□□ a □□□□□ □□□□□□□□ to this □□□□□□□ — □□□□□ suffix trees. However, it □□ not as □□□□□□□□□ as this one (run □□□□ O(N log N) and more overhead for building suffix trees) and □□ more complicated to implement. If you □□□ interested, read Wikipedia’s article about □□□□□□□ Palindromic Substring.
  • What if you □□□ □□□□□□□□ to □□□□ the □□□□□□□ palindromic subsequence? (Do you know the □□□□□□□□□□ between substring and □□□□□□□□□□□□□

□□□□□□ Links:
» □□□□□□□□’s Algorithm O(N) 时间求字符串的最长回文子串 (Best explanation if you can □□□□ Chinese)
» A simple linear □□□□ algorithm for finding longest palindrome sub-string
» Finding Palindromes
» Finding the □□□□□□□ □□□□□□□□□□□ Substring in Linear □□□□
» Wikipedia: □□□□□□□ Palindromic □□□□□□□□□

□□□□ [1.9.22_1171]
Rating: □□□□ □□□ votes cast)
Longest Palindromic Substring Part II, □□□ out of 5 □□□□□ on □□ □□□□□□□

EBay Inc (EBAY), the company that maintains

$2.55  Already Paid?
EBay Inc (EBAY), the □□□□□□□ that maintains an e-commerce □□□□□□□□ by the □□□□ name, has announced its □□□□□□ □□□□□□□ in the mobile marketing space. The move will open another □□□□ of revenues for the □□□□□□□ by providing marketers an □□□□□□□□□□□ to □□□ about □□□ million daily visitors. The □□□□□□□ □□ partnering with Triad Retail □□□□□ of □□□ Petersburg, which will □□□□□ the □□□ on eBay's platform. This represents eBay's first □□□□□□□ into handheld device advertising, spanning over smartphones and tablets. The □□□□□□□ □□□ already managed to line up Geico insurance □□□□ of □□□□□□□□□ Hathaway to market their □□□□□□□□ via its new product. EBay’s app has □□□□ downloaded □□□ □□□□□□□ □□□□□ and commands high user-engagement levels. The □□□□□□□ claims that users, on average, spend three times more time on the app compared to its closest rival, without revealing a name. The □□□□□□□ □□□ □□□ million active □□□□□ in 2013. Last year, sales from eBay’s online □□□□□□□□ totaled □□□ billion. This gave the company a unique advantage, as it understands consumer buying patterns based on □□□□□□□□□ they □□□□ □□□□ in the past. The □□□□□□□ □□□ followed □□□ □□□□□□□ hours of shopping behavior, which it can □□□□□□□□□□ to □□□□□□□ advertising □□□□□□□□□□□□□ at the most pertinent □□□□□□□□□ and timings. Because eBay □□□□□ need a single login ID to □□□□□ the e-commerce space, the company's □□□□□ of users' buying behavior is not limited to one □□□□□□ but is spread across multiple devices. This will □□□□□ the □□□□□□□’s advertising □□□□□□□□□ to integrate and □□□□□□□□ its advertising over all relevant □□□□□□□ and create cohesion between them rather than treating them as stand-alone

Customer Feedback: The Good, The Bad, And The Ugly

[paypal-donation]

As a high-tech entrepreneur, I have strong engineering background but
lack of sales and marketing skills. I struggled to get new customiers
every day. Fortunately, my wife introduced me a book, “80/20 sales and
marketing” by Perry
Marshall
and his 21 sales and marketing principles. Perry rarely
steps out from his office to visit his prospects. His customers find
him first through various channels, e.g., Internet search. By
achieving the same, I could save tons of time and money; meanwhile I
am better positioning myself as an expert instead of a solicitor.
Isn’t this the dream of all small business owners? Testimonials are a
very important tool helping Perry to achieve this. He said that
testimonial is extremely powerful to generate sales leads, but hard to
get.

Why are testimonials or simply customer feedbacks so
hard to get? As a consumer, I often purchase or use products or
services such as home improvement, childcare, healthcare, electronic
gadgets, however, I rarely respond to the solicitation for feedback
from the business owners.

Customer Feedback: the bad

1. Lack of tangible, realistic, and instant benefit

The major reason why I don’t provide feedback is lack of benefit. My
time is valuable, why should I waste time and effort for nothing. The
traditional rewards for providing feedback typically include discount
for next purchase or service, opportunity to enter into drawing, earn
points which never get redeemed, or symbolic kudos purely for getting
high. None of these is attractive for me. I expect the business who
asks me to spend time and effort can offer me more tangible, realistic,
and instant reward. Shouldn’t my time and effort get compensated? A
good recent example is the class-action lawsuit from some reviewers of
Yelp. The reviews demands monetary compensation for the reviews they
post on Yelp. Badge or special permits are not sufficient to motivate
me to post any feedback.

Customer Feedback: the ugly

2. Difficult to set up and keep track

Many times when I receive email from feedback or survey
companies, I need to create an account with them before posting any
feedback. Signup may take up a few minutes to fill out a lengthy form.
I normally drop there. Sometime, I have to answer many pointless
questions such as my favorites or even my mother’s maiden name.
There’s no way I would continue from there. If I, for some reason, did
sign up, I get another account to keep track among my other thousands
of accounts. Yikes…

3. Lack of specific instruction

As a business owner, I always give very specific requirement
when I collect feedbacks, for example, “Did you get all the
information you need from my email? If no, what’s missing?” However,
most of the requests for feedback I got from other feedback or survey
companies are “I’d like to hear your feedback” or “Please tell us more
about your experience”. I don’t know how to start my feedback, unless
I have extremely good or bad experience. Most times, I’ve already
forgotten details about their services. I keep my mouth shut.

4. Feeling of being hijacked

Last month, I received repeating emails from my rental property
management company asking to provide feedback about their service. The
company asks us to share my opinion and literally demands me to give
them high rating. I was so reluctant to write any comment. I started
to use the company for a short period of time. I really didn’t know
how they can perform in the long run. The service looked good at that
time, but it doesn’t mean it will be working fine in the future.
However, I wrote something at last. There is a dilemma for me. On one
hand, I hope they can take good care of my property. I am afraid that
not providing what they want would discourage them providing good
service, or even encourage them stopping proving good service. On the
other hand, once I write and publish my temporary comment, I would
have trouble to step back. I lose the leverage of pushing business for
better service. I believe a large amount of testimonials are collected
this way. Writing text feedback is very subjective and quite often
misleading for other customers, since it inevitably includes personal
and provisional judgment, instead of intrinsic quality.

5. Afraid of being judged

I am not used to voice my opinion publicly, especially in front
of people who know me. Each time I commented on a very subjective
topic, the first thing worries me is what would John or Amy thinks of
me. Did I make a fool of myself? I don’t like this feeling.

I am sure there are more reasons for not providing feedback. I
don’t think I am specifically challenging, regarding providing
feedback. That’s why it is so hard for business to collect feedback.

So I, as a business owner, want feedback and testimonials from
my customers; on the other hand, as a customer, I don’t want provide
feedback. How can we close the loop here? I will talk about it in my
next blog.

Hello

[wp_paywall]

Feedback