PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/WeRide

Implement matrix multiplication and fast exponentiation

Last updated: Mar 29, 2026

Quick Overview

This question evaluates competency in matrix multiplication, modular arithmetic, and exponentiation algorithms as applied to large-scale numeric computations such as sequence generation.

  • medium
  • WeRide
  • Coding & Algorithms
  • Software Engineer

Implement matrix multiplication and fast exponentiation

Company: WeRide

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

## 1) - `A` `n × m` - `B` `m × p` `C = A × B``n × p` - - - `MOD` `MOD` ## 2) Exponentiation by Squaring `x` `k` `MOD` - `x^k` - `x^k mod MOD` - `O(log k)` - `k = 0``x = 0` ## 3) `n (n ≥ 0)` `n` `F(n)` - `F(0)=0, F(1)=1` - `F(n)=F(n-1)+F(n-2)` - `2×2` `O(log n)` - `MOD` ### / - `multiply(A, B) -> C` - `pow(x, k, MOD=None) -> value` - `fib(n, MOD=None) -> value` ### - `n` `10^9` DP -

Quick Answer: This question evaluates competency in matrix multiplication, modular arithmetic, and exponentiation algorithms as applied to large-scale numeric computations such as sequence generation.

Related Interview Questions

  • Implement Several Core Algorithmic Components - WeRide (medium)
  • Validate Bracket Sequence - WeRide (medium)
  • Implement expression expansion to plus-only form - WeRide (Medium)
  • Expand algebraic expression with distribution - WeRide (Medium)
WeRide logo
WeRide
Oct 2, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
8
0

1)

  • A n × m
  • B m × p

C = A × B``n × p

  • MOD MOD

2) Exponentiation by Squaring

x k MOD

  • x^k
  • x^k mod MOD
  • O(log k)
  • k = 0``x = 0

3)

n (n ≥ 0) n F(n)

  • F(0)=0, F(1)=1
  • F(n)=F(n-1)+F(n-2)
  • 2×2 O(log n)
  • MOD

/

  • multiply(A, B) -> C
  • pow(x, k, MOD=None) -> value
  • fib(n, MOD=None) -> value

  • n 10^9 DP

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More WeRide•More Software Engineer•WeRide Software Engineer•WeRide Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,000+ 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.