All Questions
13 questions
4
votes
4
answers
2k
views
Check if a binary tree is symmetric in Python
I have solved the following Leetcode problem.
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree [1,2,2,3,4,4,3] is symmetric....
1
vote
1
answer
207
views
Maximum Width binary tree
Here is my code for the LeetCode problem
For a given binary tree, find the maximum width of the binary tree. The width of one level is defined as the length between the end-nodes even if there are <...
8
votes
2
answers
2k
views
Word-Ladder solver in Python 3
Follow-up to Python program to find a word ladder transforming "four" to "five"
I'm trying to write a program to solve a word ladder puzzle to brush up on my Python. For those who ...
1
vote
1
answer
490
views
Python program for Word Search II
This is a Leetcode problem -
Given a 2D board and a list of words from the dictionary, find all
words in the board.
Each word must be constructed from letters of a sequentially adjacent
...
-4
votes
1
answer
94
views
Finding the sublist with best utility function among all list's permutations [closed]
I try to find the the better solution in terms of time complexity.
Among the list of elements I need to find the sublist with maximum value of given utility function.
Each element has it's own type. ...
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 ...
1
vote
1
answer
2k
views
Generating and finding parent nodes in a post-order tree
Given a height h and list q of integers, list the parent node of
each element in q, if nodes are read in post-order sequence ...
6
votes
2
answers
963
views
HackerRank Binary search tree validation
From here:
...
3
votes
1
answer
2k
views
"The Story of a Tree" solved using depth-first search
Found this problem in hackerrank.
One day Bob drew a tree, with \$n\$ nodes and \$n-1\$ edges on a piece of paper. He soon discovered that parent of a node depends on the root of the tree. The ...
4
votes
1
answer
174
views
Counting increasing subsequences with a "hacker's" Binary Index Tree
This is an \$O(n \sqrt n)\$ solution to the the following problem:
Given a sequence, compute the number of non-empty increasing subsequences
The algorithm is to compute ...
3
votes
1
answer
1k
views
Request for memory optimizations for solution to Google FooBar challenge, "ion_flux_relabeling,"
I just finished one of the Google FooBar Challenges.My Python is super rusty. I did the challenge in Haskell first and then attempted to covert the code. I am guessing that led to some bad Python ...
16
votes
5
answers
9k
views
Google Foobar Challenge: Lucky Triples
Note: Since my time has passed for this challenge, I do not remember exactly the stipulations but will attempt to recapitulate them to the best of my knowledge.
Essentially, the challenge was this:
...
6
votes
2
answers
661
views
"File Fix-it" challenge
I'm learning Python and have found this problem from Google Code Jam:
How many mkdir commands does it take to construct a given directory tree:
Input
The first ...