Skip to main content

All Questions

17 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
3 votes
0 answers
311 views

LeetCode: Stone Game C#

https://leetcode.com/problems/stone-game/ Alex and Lee play a game with piles of stones. There are an even number of piles arranged in a row, and each pile has a positive integer number of stones ...
Gilad's user avatar
  • 5,253
3 votes
0 answers
230 views

Longest palindrome code in C# takes time out on LeetCode

I like to request a review of the code below, which is my attempt at answering the question here on LeetCode site. The code passes 43 tests, but it times out on the next one. I copied and ran the test ...
Shahin's user avatar
  • 103
3 votes
0 answers
787 views

Hackerrank: Sherlock and anagram (optimal time complexity)

Problem statement Given a string \$S\$, find the number of "unordered anagrammatic pairs" of substrings. Input Format First line contains \$T\$, the number of testcases. Each testcase ...
Jianmin Chen's user avatar
  • 2,396
3 votes
0 answers
680 views

Hackerearth Simple Function - Follow-up

Problem statement Let us first describe a SimpleFunction: ...
Jianmin Chen's user avatar
  • 2,396
3 votes
0 answers
1k views

Solving the Mining algorithm from HackerRank

I was working on this problem for a few hours last night and finally came up with a brute-force solution. The task is to report the minimum work necessary (sum of weight × distance) to relocate gold ...
jamkin89's user avatar
3 votes
0 answers
410 views

CodeEval - Lucky Tickets challenge

This a solution to the CodeEval's challenge "Lucky Tickets". After a failed attempt with brute-force calculations (no surprise here), I have tried to implement an algorithm that I found on ...
Slyvain's user avatar
  • 131
2 votes
0 answers
646 views

LeetCode: trapping rain water C#

Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. The above elevation map is represented by array [...
Gilad's user avatar
  • 5,253
2 votes
0 answers
920 views

Frog Jump time complexity

I have tried to work out the Frog Jump task on Codility. The algorithm for solving this is rather simple but the maximum score I am able to achieve is 55% (also 44% with modulus operations). A ...
Kris's user avatar
  • 199
2 votes
0 answers
610 views

Leetcode 10: Regular Expression Matching

Problem statement Implement regular expression matching with support for '.' and '*'. '.' Matches any single character. '*' Matches zero or more of the preceding element. The matching ...
Jianmin Chen's user avatar
  • 2,396
2 votes
0 answers
286 views

Learn trie through Leetcode 212

Problem statement: 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 sequentially adjacent cell, where "...
Jianmin Chen's user avatar
  • 2,396
2 votes
0 answers
3k views

Hackerrank: Max Score

Problem statement Consider an n-element sequence of integers, A = {a0, a0, ..., an-1}. We want to perform \$n\$ operations on \$A\$, where each operation is defined by the following sequence of ...
Jianmin Chen's user avatar
  • 2,396
2 votes
0 answers
2k views

Leetcode 317: Shortest distance from all buildings

Problem statement: You want to build a house on an empty land which reaches all buildings in the shortest amount of distance. You can only move up, down, left and right. You are given a ...
Jianmin Chen's user avatar
  • 2,396
2 votes
0 answers
564 views

HackerRank university codesprint array construction

Problem statement Professor GukiZ has hobby — constructing different arrays. His best student, Nenad, gave him the following task that he just can't manage to solve: Construct an \$n\$-...
Jianmin Chen's user avatar
  • 2,396
2 votes
0 answers
2k views

HackerRank - Matrix Rotation

Problem statement Given a matrix (up to 300 × 300), rotate each element R steps anti-clockwise along concentric rectangular paths (R up to 109). The algorithm is rated as hard on HackerRank. On ...
Jianmin Chen's user avatar
  • 2,396
2 votes
1 answer
272 views

LeetCode: House Robber II C#

https://leetcode.com/problems/house-robber-ii/ You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place ...
Gilad's user avatar
  • 5,253
1 vote
0 answers
302 views

LeetCode:MineSweeper C#

https://leetcode.com/problems/minesweeper/ please review for performance. I really don't like the implementation I made for GetNumberOfMines() function, but within the time limits i did this. it is ...
Gilad's user avatar
  • 5,253
1 vote
0 answers
894 views

Hackerrank > Woman's CodeSprint 2 > stone division, Revisited ( recursive function)

Problem statement You have a pile of n stones that you want to split into multiple piles, as well as a set, S, of ...
Jianmin Chen's user avatar
  • 2,396