PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Akuna Capital

Solve sliding window, graph top-k, and greedy tasks

Last updated: Mar 29, 2026

Quick Overview

This multi-part question evaluates proficiency in algorithm design and data-structure use across sliding-window string processing, top-k aggregation on weighted graphs, and greedy counting on binary arrays within the Coding & Algorithms domain, emphasizing string and graph algorithms, top-k/heap techniques, and greedy pattern recognition.

  • Medium
  • Akuna Capital
  • Coding & Algorithms
  • Data Scientist

Solve sliding window, graph top-k, and greedy tasks

Company: Akuna Capital

Role: Data Scientist

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Take-home Project

You have three coding tasks. Task 1 — Sliding window on strings: Given a string s and an integer k, find one longest substring of s that contains at most k distinct characters. Return the start index and length of such a substring (return the earliest start if multiple solutions have the same length). Aim for O(n) time and O(k) extra space using a sliding window. Task 2 — Top-k positive neighbors in a weighted graph: Given an undirected weighted graph with n nodes labeled 0..n-1 and an edge list edges where each edge is (u, v, w) with integer weight w (possibly negative), compute for every node v the sum of the weights of up to k incident edges with the largest positive weights. If a node has no incident edges with positive weight, its sum is 0. Return an array sums of length n where sums[v] is that sum. Target complexity O(m log k) time and O(n + m) space, where m = |edges|. Task 3 — Greedy counting on a binary array: Given an array A of length n consisting only of 0s and 1s, compute the total number of pairs (i, j) such that i < j, A[i] = 1, and A[j] = 0. Interpret this value as the minimum number of adjacent swaps needed to move all 1s to the end of the array. Aim for O(n) time and O( 1) extra space by maintaining a running count of 1s encountered.

Quick Answer: This multi-part question evaluates proficiency in algorithm design and data-structure use across sliding-window string processing, top-k aggregation on weighted graphs, and greedy counting on binary arrays within the Coding & Algorithms domain, emphasizing string and graph algorithms, top-k/heap techniques, and greedy pattern recognition.

Related Interview Questions

  • Find minimum swaps to sort array with duplicates - Akuna Capital (hard)
  • Heapify an array into a max-heap - Akuna Capital (Medium)
  • Implement a ring buffer - Akuna Capital (Medium)
  • Compute max profit across dated stock quotes - Akuna Capital (Medium)
  • Break a palindrome to smallest non-palindrome - Akuna Capital (Medium)
Akuna Capital logo
Akuna Capital
Aug 12, 2025, 12:00 AM
Data Scientist
Take-home Project
Coding & Algorithms
1
0

You have three coding tasks.

Task 1 — Sliding window on strings: Given a string s and an integer k, find one longest substring of s that contains at most k distinct characters. Return the start index and length of such a substring (return the earliest start if multiple solutions have the same length). Aim for O(n) time and O(k) extra space using a sliding window.

Task 2 — Top-k positive neighbors in a weighted graph: Given an undirected weighted graph with n nodes labeled 0..n-1 and an edge list edges where each edge is (u, v, w) with integer weight w (possibly negative), compute for every node v the sum of the weights of up to k incident edges with the largest positive weights. If a node has no incident edges with positive weight, its sum is 0. Return an array sums of length n where sums[v] is that sum. Target complexity O(m log k) time and O(n + m) space, where m = |edges|.

Task 3 — Greedy counting on a binary array: Given an array A of length n consisting only of 0s and 1s, compute the total number of pairs (i, j) such that i < j, A[i] = 1, and A[j] = 0. Interpret this value as the minimum number of adjacent swaps needed to move all 1s to the end of the array. Aim for O(n) time and O(

  1. extra space by maintaining a running count of 1s encountered.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Akuna Capital•More Data Scientist•Akuna Capital Data Scientist•Akuna Capital Coding & Algorithms•Data Scientist Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.