[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-7861":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":15,"stars7d":15,"stars30d":15,"stars90d":15,"forks30d":15,"starsTrendScore":15,"compositeScore":16,"rankGlobal":9,"rankLanguage":9,"license":9,"archived":17,"fork":17,"defaultBranch":18,"hasWiki":19,"hasPages":17,"topics":20,"createdAt":9,"pushedAt":9,"updatedAt":25,"readmeContent":26,"aiSummary":27,"trendingCount":15,"starSnapshotCount":15,"syncStatus":28,"lastSyncTime":29,"discoverSource":30},7861,"algorithms","sagivo\u002Falgorithms","sagivo","algorithms playground for common questions",null,"Ruby",3250,353,132,1,0,56.65,false,"master",true,[21,22,23,24],"algorithm","computer-science","interview-questions","ruby","2026-06-12 04:00:36","Algorithms\n==========\n\nAlgorithms playground for common questions solved in ruby syntax.  \nIn case you want to prepare yourself for a job interview - try to solve it yourself first, then have a look here.  \n\n# Why?\nI interviewed with [Google](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Fgoogle-interview-tips.md), [Facebook](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Ffacebook-interview-tips.md), [LinkedIn](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Flinkedin-interview.md), Twitter and others. I also interviewed others myself.\nSometimes it looks like they all ask you the same \"out of the box\" questions that don't really check knowledge but memorization of the same tricks.\nThis is my way of saying - change your interview style. There are lots of smart people out there, this is not the best way to find them.\n\n# Problems\n\n| problem                                                                                                                                                                                 | solution                                                                                                                                                                              |\n|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Unique binary search trees](https:\u002F\u002Fleetcode.com\u002Fproblems\u002Funique-binary-search-trees\u002Fdescription\u002F)                                                                                                                         | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Funique_bsts.rb)                                                                                                                   |\n| [House Robber](https:\u002F\u002Fleetcode.com\u002Fproblems\u002Fhouse-robber\u002Fdescription\u002F)                                                                                                                         | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Fhouse-robber.rb)                                                                                                                   |\n| [Decode Ways](https:\u002F\u002Fleetcode.com\u002Fproblems\u002Fdecode-ways)                                                                                                                         | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Fdecode_ways.rb)                                                                                                                   |\n| [Coin change](https:\u002F\u002Fleetcode.com\u002Fproblems\u002Fcoin-change\u002Fdescription\u002F)                                                                                                                         | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Fcoin-change.rb)                                                                                                                   |\n| [Decode Strings](https:\u002F\u002Fleetcode.com\u002Fproblems\u002Fdecode-string\u002Fdescription\u002F)                                                                                                                         | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Fdecode_string.rb)                                                                                                                   |\n| [Wiggle Subsequence](https:\u002F\u002Fleetcode.com\u002Fproblems\u002Fwiggle-subsequence\u002Fdescription\u002F)                                                                                                                         | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Fwiggle_subsequence.rb)                                                                                                                   |\n| [Binary Tree Side View](https:\u002F\u002Fleetcode.com\u002Fproblems\u002Fbinary-tree-right-side-view\u002Fdescription\u002F)                                                                                                                         | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Fbinary_tree_side_view.rb)                                                                                                                   |\n| [Unix path](https:\u002F\u002Fleetcode.com\u002Fproblems\u002Fsimplify-path\u002Fdescription\u002F)                                                                                                                         | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Fsimplify_path.rb)                                                                                                                   |\n| [Array Product](https:\u002F\u002Fleetcode.com\u002Fproblems\u002Fproduct-of-array-except-self\u002Fdescription\u002F)                                                                                                                         | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Fproduct-of-array.rb)                                                                                                                   |\n| [Top K Frequent Elements](https:\u002F\u002Fleetcode.com\u002Fproblems\u002Ftop-k-frequent-elements\u002Fdescription\u002F)                                                                                                                         | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Ftop-k-elements.rb)                                                                                                                   |\n| [Sum 4 arrays](https:\u002F\u002Fleetcode.com\u002Fproblems\u002F4sum-ii\u002Fdescription\u002F)                                                                                                                         | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002F4-sum.rb)                                                                                                                   |\n| [Reverse Linked List](https:\u002F\u002Fleetcode.com\u002Fproblems\u002Freverse-linked-list\u002Fdescription\u002F)                                                                                                                         | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Freverse-linked-list.rb)                                                                                                                   |\n| [Reverse String In-place](https:\u002F\u002Fleetcode.com\u002Fproblems\u002Freverse-string\u002Fdescription\u002F)                                                                                                                         | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Freverse-string-inplace.rb)                                                                                                                   |\n| [Nested List Weight Sum II](https:\u002F\u002Fleetcode.com\u002Fproblems\u002Fnested-list-weight-sum-ii\u002F)                                                                                                                         | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Fnested_list_weight_sum_ii.rb)                                                                                                                   |\n| [Symmetric Tree](https:\u002F\u002Fleetcode.com\u002Fproblems\u002Fsymmetric-tree\u002F)                                                                                                                         | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Fmirror.rb)                                                                                                                   |\n| [Dijkstra's shortest path between two nodes](https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FDijkstra%27s_algorithm)                                                                                      | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Fdijkstra.rb)                                                                                                                 |\n| [Kruskal's minimum spanning tree algorithm](http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FKruskal%27s_algorithm)                                                                                         | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Fkruskal.rb)                                                                                                                  |\n| [Find the square root of a number](https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FNewton%27s_method)                                                                                                     | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Fsq_root.rb)                                                                                                                  |\n| [Add two binary numbers](https:\u002F\u002Fleetcode.com\u002Fproblems\u002Fadd-binary\u002Fdescription\u002F)                                                                                                     | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Fadd_binary.rb)                                                                                                                  |\n| [Binary search](https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FBinary_search_algorithm)                                                                                                                  | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Fbinary_search.rb)                                                                                                            |\n| [Longest increasing subsequence](http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FLongest_increasing_subsequence)                                                                                           | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Flongest_increasing_subsequence.rb)                                                                                           |\n| [Find all permutations of array](https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FPermutation)                                                                                                             | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Fpermutations.rb)                                                                                                             |\n| [Finding all combinations of well-formed brackets](http:\u002F\u002Fstackoverflow.com\u002Fquestions\u002F727707\u002Ffinding-all-combinations-of-well-formed-brackets)                                          | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Fbrackets_combinations.rb)                                                                                                    |\n| [Finding the powerset of a set](http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FPower_set)                                                                                                                 | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Fpowerset.rb)                                                                                                                 |\n| [Game of life](https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FConway%27s_Game_of_Life)                                                                                                                   | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Fgame_of_life.rb)                                                                                                             |\n| Print all combinations of set joining                                                                                                                                                   | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Fjoin_sets.rb)                                                                                                                |\n| [count and say](https:\u002F\u002Fleetcode.com\u002Fproblems\u002Fcount-and-say\u002F)                                                                                                                                                   | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Fcount_and_say.rb)                                                                                                                |\n| [Telephone number to words](http:\u002F\u002Fwww.mobilefish.com\u002Fservices\u002Fphonenumber_words\u002Fphonenumber_words.php)                                                                                 | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Fphone.rb)                                                                                                                    |\n| [Maximum contiguous subarray](https:\u002F\u002Fleetcode.com\u002Fproblems\u002Fmaximum-subarray)                                                                                 | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Fmax_subarray.rb)                                                                                                                    |\n| [Max Stack](https:\u002F\u002Fleetcode.com\u002Fproblems\u002Fmax-stack\u002Fsubmissions\u002F)                                                                                 | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Fmax_stack.rb)                                                                                                                    |\n| [Find the smallest biggest number that has the same digits](http:\u002F\u002Fstackoverflow.com\u002Fquestions\u002F9368205\u002Fgiven-a-number-find-the-next-higher-number-which-has-the-exact-same-set-of-digi) | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Fbigger_num_with_same_digits.rb)                                                                                              |\n| [Find the minimum insertions needed to make a word palindrome](http:\u002F\u002Fwww.geeksforgeeks.org\u002Fdynamic-programming-set-28-minimum-insertions-to-form-a-palindrome\u002F)                   | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Fmin_insertions_for_palindrome.rb)                                                                                            |\n| [String matching - Knuth Morris Pratt algorithm KMP](http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FKnuth%E2%80%93Morris%E2%80%93Pratt_algorithm)                                                         | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Fkmp.rb)                                                                                                                      |\n| [Balanced Parentheses](http:\u002F\u002Fstackoverflow.com\u002Fquestions\u002F14930073\u002Fhow-to-check-if-a-string-is-balanced)                                                                                | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Fbalanced_parentheses.rb)                                                                                                     |\n| [Quicksort algorithm](http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FQuicksort)                                                                                                                           | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Fquicksort.rb)                                                                                                                |\n| [Mergesort algorithm](https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FMerge_sort)                                                                                                                         | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Fmerge_sort.rb)                                                                                                               |\n| [Max Stocks Profit](https:\u002F\u002Fleetcode.com\u002Fproblems\u002Fbest-time-to-buy-and-sell-stock\u002F)                                                                                                                         | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Fstocks.rb)                                                                                                               |\n| [Countingsort algorithm](http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FCounting_sort)                                                                                                                    | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Fcounting_sort.rb)                                                                                                            |\n| [Shellsort algorithm](http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FShellsort)                                                                                                                           | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Fshell_sort.rb)                                                                                                               |\n| [Knapsack problem](http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FKnapsack_problem)                                                                                                                       | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Fknapsack.rb), [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Fknapsack2.rb)                                                                                                                 |\n| [Move Zeroes](https:\u002F\u002Fleetcode.com\u002Fproblems\u002Fmove-zeroes)                                                                                                                       | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Fmove_zeroes.rb)                                                                                                                 |\n| [Longest common subsequence problem](https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FLongest_common_subsequence_problem)                                                                                  | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Flongest_common_subsequence.rb) , [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Flongest_increasing_subsequence.rb) |\n| [Monty Hall Problem](https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FMonty_hall_problem)                                                                                                                  | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Fmonty_hall.rb)                                                                                                               |\n| [Eucliden and Extended Eucliden algorithm](http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FExtended_Euclidean_algorithm)                                                                                                                  | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Fgcd.rb)                                                                                                               |\n| Suggest index of a number in an array                                                                                                                  | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Fsugget_index_in_array.rb)                                                                                                               |\n| [Range minimum query sparse table algorithm](http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FRange_minimum_query)                                                                                                                  | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Frmq.rb)                                                                                                               |\n| [Insertion Sort](https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FInsertion_sort)                                                                | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Finsertion_sort.rb)                                                                                                               |\n| [Towers of Hanoi using Stack](https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FTower_of_Hanoi) | [click](blob\u002Fmaster\u002Fsrc\u002Ftowers_of_hanoi_with_stack.rb)\n| [Tarjan's strongly connected components finder](https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FTarjan%27s_strongly_connected_components_algorithm)                                                                | [click](https:\u002F\u002Fgithub.com\u002Fsagivo\u002Falgorithms\u002Fblob\u002Fmaster\u002Fsrc\u002Ftarjan.rb)                                                   |\n\n\n# How?  \nSimply run `ruby some_file.rb` to execute the algorithm. At the bottom of each file there are some test samples.  \nexample: `ruby brackets_combinations.rb` will print:  \n`[\"((()))\", \"(()())\", \"(())()\", \"()(())\", \"()()()\"]`.  \n\n# Contribute\nDid you find a bug? any way to do it better? please feel free to pull-request it :)\n","该项目是一个用 Ruby 语言编写的算法练习场，旨在帮助开发者解决常见的编程问题。它涵盖了多种经典算法题目及其解决方案，特别适用于准备技术面试的程序员。通过提供详细的代码示例，该项目能够帮助用户加深对算法的理解，并提高解决问题的能力。此外，项目作者基于自己在多家知名公司（如Google、Facebook等）的面试经验分享了一些实用建议，使得这个资源不仅限于代码学习，还包含了宝贵的面试技巧。适合任何希望提升个人算法能力或为即将到来的技术面试做准备的人士使用。",2,"2026-06-11 03:14:46","top_language"]