Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 142974

Use this tag when the code is a solution to a programming challenge. Always include a sufficient description of the problem to be solved - while a link to the challenge is welcome, the review request needs to be complete when the challenge site is unavailable.

10 votes
2 answers
4k views

Generate all valid combinations of n pair of parentheses

Implement an algorithm to print all valid (e.g. properly opened and closed) combinations of n pair of parentheses. Following is my implementation and I think it works. Is the algorithm efficien …
Stack crashed's user avatar
12 votes
3 answers
2k views

Given some integers, return the k most frequent elements

Given a non-empty array of integers, return the k most frequent elements. For example, given [1,1,1,2,2,3] and k = 2, return [1,2]. Following is my submission to this problem on Leetcode and it is a …
Stack crashed's user avatar
2 votes
1 answer
2k views

Given a binary tree, find the maximum path sum

This is a leetcode.com problem. For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connections. The path must …
Stack crashed's user avatar
2 votes
1 answer
950 views

Merge K Sorted List

Merge k sorted linked lists and return it as one sorted list. The definition of the ListNode class and the signature of the MergeKLists method can't be modified. Below is my submission to LeetCod …
Stack crashed's user avatar
5 votes
1 answer
595 views

Compute all valid configuration of eight queens on a 8x8 chess board

Write an algorithm to print all valid ways of arranging eight queens on an 8x8 chess board so that none of them attack any other. Following is my code for this. Do you see any performance or co …
Stack crashed's user avatar
2 votes
2 answers
1k views

Count of Smaller Numbers After Self

This is a LeetCode.com problem. https://leetcode.com/problems/count-of-smaller-numbers-after-self/description/ You are given an integer array nums and you have to return a new counts array. The …
Stack crashed's user avatar
4 votes
2 answers
1k views

Given two words and a dictionary's word list, find all shortest transformation sequence

This is a leetcode problem (https://leetcode.com/problems/word-ladder-ii/description/) Given two words (beginWord and endWord), and a dictionary's word list, find all shortest transformation sequence …
Stack crashed's user avatar
4 votes
1 answer
5k views

Compute power set of a given set in Python

Problem: Given a set (let's say of integers), return the list of all of its subsets also known as the power set. It looks to be working, but I would like feedback on the algorithm and Python cod …
Stack crashed's user avatar
1 vote
1 answer
838 views

Compute the number of ways a given amount (cents) can be changed

Given an infinite number of different coin types (such as pennies, nickels, dimes, quarters) find out how many ways n cents can be represented. My code appears to work (although I am curious …
Stack crashed's user avatar
1 vote

Generate all permutations of a list in Python

The algorithm as you have intended looks ok to me. However I have a few comments about the algorithm's efficiency. With the current approach you will regenerate the same permutation many times if th …
Stack crashed's user avatar