TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Balance LHS = RHS

1 点作者 hackerdad超过 7 年前
While helping my 5th grader kid, I came across a question from his math text book about using parenthesis to evaluate the expression.<p>The questions and examples were simple enough for fifth grader but the generalization of the same seems like a hard problem.<p>Here is the problem when generalized:<p>1. You are given an equation of the form LHS = RHS.<p>2. LHS is a mathematical expression on real numbers with +, -, * and &#x2F; operations.<p>3. RHS is a single numerical value (real number).<p>4. LHS != RHS<p><i></i>Given above, modify the LHS such that by adding one or more groups of parenthesis, LHS == RHS.<i></i><p>Find the Big O time complexity for the algorithm<p>Example 1<p><i></i>Input<i></i><p>200 - 60 &#x2F; 5 = 28<p><i></i>Output<i></i><p>(200 - 60)&#x2F;5 = 28<p>Example 2<p><i></i>Input<i></i><p>12 + 3 * 17 - 3 * 2 = 108<p><i></i>Output<i></i><p>(12 + 3 * (17 - 3)) * 2 = 108<p>Hoping to start a thread discussing the solutions

暂无评论

暂无评论