自分がコーディング面接対策のために解いてよかった LeetCode の問題をコンセプトごとにまとめました。カバーするコンセプトは LinkedList Stack Heap, PriorityQueue HashMap Graph, BFS, DFS Tree, BT, BST Sort Dynamic Programming Binary search Recursion Sliding window Greedy + Backtracking です。 これらの問題が 30 分以内に実装できれば面接の準備は整ったと言っていいと思います。Easy と Medium で問題は構成されてます。進捗を管理するためにGoogle Spreadsheetを用意しました。コピペしてご自由にお使いください。 これらの問題は、LeetCode のリスト機能でも公開されています。クローンすれば自分がすでにど
このとき、最初(左)から数えて、 o の連続して出た数を数え、その最大値に注目します。上記の例では、 Aさんが最も多く、2回ですね。 さて、コイントスの表裏が出る確率がそれぞれ 50% (つまり、完全にランダム)であったと仮定した場合、連続して2回表が出る確率は以下ですよね。 (1/2)^2 = 1/4 そうすると、どれだけコイントスを試行したか (≒どれだけの人数がいたか) 考えたときに、最も確率が高いのは4回です。つまり総人数は4人! こう数えることには、大きな利点があります。それは、 ある人が既にカウントされたかどうかを記録しておく必要がない ということです。なぜなら、 o が続いた最大数だけを覚えておけばいいので。これは、特に大きな人数集団であった場合には特に嬉しいですよね。 いやいや、大雑把すぎるだろとか、色々聞こえてきそうです。それは次のセクション以降で説明していきます。ただし
If you want to solve a tricky problem, it often helps to get organized. You might, for example, break the problem into pieces and tackle the easiest pieces first. But this kind of sorting has a cost. You may end up spending too much time putting the pieces in order. This dilemma is especially relevant to one of the most iconic problems in computer science: finding the shortest path from a specific
I was playing with my son’s Rubik’s Cubes and tried to scramble a cube randomly so that no two squares with the same color were side by side. Here’s one way to do it: But I wanted a scramble that looked like a random scramble. No matter how many different moves I made, I couldn’t do it. Every time I separated two squares with the same color, two other squares of the same color would touch somewher
Deleted articles cannot be recovered. Draft of this article would be also deleted. Are you sure you want to delete this article? 0. はじめに --- グラフ探索の動機 現代ではコンピュータはとても身近なものになりました。コンピュータの用途としては シミュレーションなどの大規模計算を行う 人工知能をつくる アプリを開発する などなど多様なものが考えられますが、「探索」もまた、コンピュータを用いるモチベーションとして、最も基本的かつ重要なものの一つだと思います。探索とは、与えられた対象の中から、目的に合うものを見つけ出したり、最良のものを見つけ出したり、条件を満たすものを列挙したりする営みです。 世の中における様々な問題は、探索によって、考えられる場合を調べ尽くす
アルゴリズム初心者向けの基礎と入門(C#, Pythonとか) ソート ソートアルゴリズム バブルソート 選択ソート 挿入ソート シェルソート クイックソート マージソート ヒープソート バケットソート 基数ソート 奇遇転置ソート 探索 線形探索法(リニアサーチ) 二分探索法(バイナリサーチ) 幅優先探索 深さ優先探索 文字列探索 力まかせ探索 クヌース–モリス–プラット法(KMP法) ボイヤー・ムーア法(BM法) 圧縮 圧縮アルゴリズム ランレングス圧縮(連長圧縮) ハフマン符号 エンコード・デコード Base64 QuotedPrintable 数値計算 フィボナッチ数 エラトステネスの篩 ユークリッドの互除法 ゲーム・パズル 迷路生成(棒倒し法) 迷路生成(壁伸ばし法) 迷路生成(穴掘り法) ライフゲーム AI 遺伝的アルゴリズム 乱数生成 線形合同法
Finding the median in a list seems like a trivial problem, but doing so in linear time turns out to be tricky. In this post I’m going to walk through one of my favorite algorithms, the median-of-medians approach to find the median of a list in deterministic linear time. Although proving that this algorithm runs in linear time is a bit tricky, this post is targeted at readers with only a basic leve
Warning! The code (ASM) part of this article is not fully correct and doesn't scale to more layers of the tree. While I solved this problem offline, I did not update this article. Once I do, this warning will be off. Recently, I've been looking at cache friendly algorithm for common data structures like trees, tries, ... One such algorithm kept coming up to mind and that's why I decided to impleme
1. BackgroundUGCの順序を更新する際のデータ更新が非効率だなと思っていたのがこの記事を書こうと思ったきっかけです。 Pairsでは、インクリメンタルなインデックスを付与することでUGCの順序を保持しています。 type UserImage struct { ID int UserID int Index int // 0が最小の並び順のインデックス Path string // 画像のパス } type UserImages []UserImage func (e *UserImages) Sort() { sort.Slice(e, func(i, j int) bool { return e[i].Index < e[j].Index }) } var userImages = UserImages{ {ID: 1, UserID: 200, Index: 1, Path
MLU-EXPLAIN Visual explanations of core machine learning concepts Machine Learning University (MLU) is an education initiative from Amazon designed to teach machine learning theory and practical application. As part of that goal, MLU-Explain exists to teach important machine learning concepts through visual essays in a fun, informative, and accessible manner. Neural Networks Learn about neural net
米ハーバード大学がオンラインで無料公開している、PythonやJavaScriptのプログラミング学習とコンピューターサイエンスの入門講座の日本語訳ページ「CS50.jp」が無償公開されました。2022年8月31日に2022年度最新版の日本語化が完了しました。講義動画の日本語字幕の翻訳化を順次すすめています。学生向けですが、年代にかかわらず、コロナ禍で学習環境やキャリアに悩んでいる誰もが学ぶことができます。 ハーバード大学のCS50xとは ハーバード大学のCS50xとは、日本語翻訳ページ「CS50.jp」によると、コンピューターサイエンスとプログラミング技術を紹介するオンラインコースです。この講義がオンライン上で無償公開されており、世界で282万人が履修登録しています。 edX - CS50s Introduction to Computer Science 学べる内容はPythonのプロ
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く